Even or odd

Finds out whether a number is even. Teaches conditions and the remainder %.

Open in Tokbit Level: Beginner. Free in the browser, nothing to install, no account needed.

Run the example in Tokbit and step through it: before each step say what will happen and check it in the Variables panel. Then change it your way.

Flowchart

Flowchart of the Even or odd example

Python program

The same program as Python code. In Tokbit you see it when you switch from Diagram to Python above the flowchart.

"""Tells whether a number is even. Teaches a condition and the remainder."""
n: int
n = int(input("Enter a whole number:"))
# An even number leaves remainder 0 when divided by two.
if n % 2 == 0:
    print(n, "is even")
else:
    print(n, "is odd")

Follow-up tasks

Tasks in which you change the example (with a model solution):

All examples