Even or odd
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Making decisions →
Even or odd
Read a whole number n with int(input()) (for example 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.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Read a whole number n with int(input()) (for example 7). Print even when n divides by 2 with no remainder, and odd otherwise.
Click Run to see the output here.