Exercise 5
Write a program in Python language that asks the user to enter an integer number 'n' and display whether this number is even or odd.
Solution
1 2 3 4 5 6 7 8 9 10 |
# Ask user to enter a value of n n = input("Type value of the integer n: ") # Convert n to integer n = int(n) # Test if n is even or not if(n%2 == 0): print("The number '", n, "' typed is even") else: print("The number '", n, "' typed is odd ") |
Younes Derfoufi
CRMEF OUJDA
Acheter sur Très Facile !
-
Maîtriser la Programmation Python pour le Machine Learning
€ 33,00 Acheter le livre -
Cahier d'algorithmique et de programmation Python: Manuel élève 1ère Tle techno
€ 9,00 Acheter le livre -
Apprendre l'intelligence artificielle avec Python : Recherche, optimisation, apprentissage
€ 32,00 Acheter le livre
1 thought on “Solution Exercise 5: test the parity of a number in python”