Skip to content · ⁨דלג לתוכן⁩

Even or odd · ⁨זוגי או אי-זוגי⁩

English

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 יסביר לך זאת.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP