max function

Question

Write a function to find the maximum of 3 numbers.

in progress 0
YashikaKhurana 55 years 6 Answers 908 views Master 0

Answers ( 6 )

  1. def max3(a,b,c):
    if (a >= b) and (a >= c):
    largest = a
    elif (b >= a) and (b >= c):
    largest = b
    else:
    largest = c
    print(largest)

  2. #Where x can be a list of any numbers (for instance 3 in this case)
    def maxi(x):
    return np.max(x)

    maxi(x)
    Will return the maximum number from the list

  3. def maxi(a,b,c):
    max=0
    if a>b:
    max=a
    else:
    max=b
    if max>c:
    return max
    else:
    return c

  4. #Python 3.6
    #let’s say we have my_numbers=[a,b,c]
    #here a,b,c are the three numbers and we have to find the largest of all
    my_number= sorted(my_number)
    print(my_number[2])

  5. def max_(a,b,c):
    return list(filter(lambda i: i==max(a,b,c), (a,b,c)))

  6. def max_of_3(x,y,z):
    if x>=y and x>=z:
    largest = x
    elif y>= x and y>=z:
    largest = y
    else:
    largest = z

    print(largest)

Leave an answer

Browse
Browse