Exercise 3
Write a program in Python that asks the user to enter two numbers a and b and display their maximum, without using the max() function or any predefined function.
Solution
1 2 3 4 5 6 7 8 9 |
# read the values of a and b a = int(input("Type the value of number a: ")) b = int(input("Type the value of number b: ")) # Do a comparison test to find the largest if (a > b): print("The maximum of a and b is: a = ", a) else: print("The maximum of a and b is: b = ", b) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 3: Python program that displays the maximum of two numbers”