Junior Codes
Willow Island

Python if Statements for Kids

Let your program decide: do something only when it is needed.

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.

if statements, explained simply

Every day you make small decisions: if it is raining, take an umbrella. Programs make decisions in the same way using the word if.

An if statement asks a yes-or-no question. If the answer is yes (Python calls it True), the indented lines underneath run. If the answer is no (False), Python skips them and carries on.

Questions usually compare things. A double equals sign == asks "are these the same?", while > and < ask "bigger than?" and "smaller than?".

Example: Only eat when hungry

energy = 2
if energy < 5:
    print("Time for a snack!")
print("Back to exploring.")

Output

Time for a snack!
Back to exploring.

Try this

  • Change energy to 8. Which line disappears, and why?
  • Write an if statement that prints "Happy birthday!" when a variable called month equals your birthday month.
  • Swap < for > and predict the output before you run it.

Practise it in Wonderwild

“A snack, only when needed”

Mission 4 in Willow Island, 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

What is the difference between = and == in Python?+

A single = stores a value in a variable. A double == compares two values and asks whether they are equal. Mixing them up is one of the most common beginner mistakes.

Do I need an else every time I use if?+

No. An if can stand on its own when you only want something to happen in one case. Use else when you also need to handle the other case.

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