Even or odd · Pair ou impair
Even or odd
n is 7. Print even when n divides by 2 with no remainder, and odd otherwise.
% gives the remainder. 7 % 2 is 1, 8 % 2 is 0. Compare it with == (two equals signs) — one equals sign means store a value, and Python will tell you so.
Pair ou impair
n vaut 7. Afficher even lorsque n est divisible par 2 sans reste, et odd sinon.
% donne le reste. 7 % 2 vaut 1, 8 % 2 vaut 0. Comparer avec == (deux signes égal) — un seul signe égal signifie stocker une valeur, et Python vous le dira.
n is 7. Print even when n divides by 2 with no remainder, and odd otherwise. · n vaut 7. Afficher even lorsque n est divisible par 2 sans reste, et odd sinon.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.