Exercise 7
Write a Python algorithm that asks the user to enter 3 numbers x, y and z and display their maximum without using any predefined function.
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Ask the user to type 3 numbers a, b, c a = int(input("Type a value of the number a ")) b = int(input("Type a value of the number b ")) c = int(input("Type a value of the number c ")) # set and initialize maximum to zero max = 0 if(a > b): max = a else: max = b if(max < c): max = c else: max = max print("The maximum of the three numbers is: max(a,b,c) = ", max) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 7: maximum of three numbers in Python”