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
Acheter sur Très Facile !
-
Lecteur Beikell de Carte Micro SD
€ 8,00 Acheter le produit -
Xenocam Caméra de sécurité extérieure WiFi 1080p sans Fil- Vision Nocturne
€ 41,00 Acheter le produit -
Promo !
TP-Link Routeur WiFi 6 Archer AX18** WiFi 6 nouvelle génération
Le prix initial était : € 40,00.€ 35,00Le prix actuel est : € 35,00. Acheter le produit
1 thought on “Solution Exercise 7: maximum of three numbers in Python”