Even or odd · זוגי או אי-זוגי
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.
זוגי או אי-זוגי
n הוא 7. הדפס even כאשר n מחולק ב2 ללא שארית, והדפס odd אחרת.
% נותן את השארית. 7 % 2 הוא 1, 8 % 2 הוא 0. השווה אותו ל== (שני סימני שוויון) — סימן שוויון אחד פירושו שמור ערך, ו-Python יסביר לך זאת.
n is 7. Print even when n divides by 2 with no remainder, and odd otherwise. · n הוא 7. הדפס even כאשר n מחולק ב2 ללא שארית, והדפס odd אחרת.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.