find max and min value in array

rajeevsinghthakur · updated October 02, 2021 · Python
def max_check(x):
  max_val = x[0] 
  for check in x: 
    if check > max_val: 
      max_val = check 
  return max_val


def min_check(x):
  min_val = x[0] 
  for check in x: 
    if check < min_val: 
      min_val = check 
  return min_val
       

arr = [50,90,6,2,0,8]
#n =len(arr)

print(max_check(arr))
print(min_check(arr))







Comments

Please sign up or log in to contribute to the discussion.