Exercise on Python function

Python Exercise: Find the Max of three numbers using function

1 Like

def find_max(a, b, c):
return max(a, b, c)

n1 = int(input("Enter the number 1 "))
n2 = int(input("Enter the number 2 "))
n3 = int(input("Enter the number 3 "))

maximum = find_max(n1, n2, n3)
print(“The maximum number is:”, maximum)

1 Like

def maximum(a, b, c):

if (a >= b) and (a >= c):
    largest = a

elif (b >= a) and (b >= c):
    largest = b
    largest = c
return largest

a = int(input(‘enter a 1st num =’))
b = int(input(“enter a 2nd num =”))
c = int(input(“enter a 3rd num =”))
print(maximum(a, b, c))

1 Like

def max():
List=list(map(int,input(“ENTER THE ELEMENTS in THE LIST :”).split()))
print (List)
print(‘MAX NUMBER IS:’,List[-1])


[15, 1, 29]
[1, 15, 29]

Very good, try to avoid using in built functions

Very good. Keep trying

Very good, try to avoid in built functions and write manually.

def find_max(a,b,c):
return max(a,b,c)

num1= float(input(“Enter the first number: “))
num2= float(input(“Enter the second number: “))
num3= float(input(“Enter the third number: “))

maximum = find_max(num1,num2,num3)
print(“The max of the three numbers is: “, max)

a=int(input(“enter first number”)
b=int(input(“enter second number”)
c=int(input(“enter third number”)
if ( a>b ) and ( a>c):
print(“a is maximum” ,a)
elif (b>a) and (b>c):
print(“b is maximum”, b)
print(“c is maximum”, c)

1 Like
num1=int(input("enter first number"))
num2=int(input("enter first number"))
num3=int(input("enter first number"))

Good try, Instead of using max try to solve it using logical functions

Good try. Intsead of using max function try to solve it using logical functions