Junior Codes
Message Harbour

Comparisons, True/False and and/or in Python for Kids

Ask yes-or-no questions and combine them with and, or and not.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Comparisons & Booleans, explained simply

A comparison is a question with only two possible answers: True or False. These two values are called Booleans, after the mathematician George Boole.

Python has six comparison signs: == (equal), != (not equal), > and < (bigger, smaller), and >= and <= (bigger or equal, smaller or equal).

You can join questions together. and is True only when both sides are True. or is True when at least one side is True. not flips True to False and False to True.

Example: A gate that needs two keys

has_gold_key = True
has_silver_key = False
print(has_gold_key and has_silver_key)
print(has_gold_key or has_silver_key)

Output

False
True

Try this

  • Change has_silver_key to True and predict both lines before you run it.
  • Print 7 > 3 and "cat" == "Cat". Was the second one what you expected?
  • Write a check that is True only if a number is between 1 and 10.

Practise it in Wonderwild

“The two-key gate”

Mission 11 in Message Harbour, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

Why is "cat" == "Cat" False?+

Python treats capital and small letters as different characters. Use .lower() on both sides first if you want the check to ignore capitals.

Where are Booleans used?+

Everywhere a program makes a decision: in if statements, while loops, game rules and login checks.

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course