Junior Codes
Willow Island

Python Variables for Kids

Give a value a name so your program can remember it and change it.

Try this mission free with Pip

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

Variables, explained simply

A variable is like a labelled box. You pick a name for the label, and put a value inside. Later, whenever you use the name, Python looks inside the box and uses whatever is there.

You create a variable with a single equals sign: lamps = 3. In Python the equals sign means "store this", not "is the same as". You can put a new value in the box at any time, and the old one is replaced.

Variables can do maths too. If you write lamps = lamps + 1, Python reads the current value, adds one, and stores the answer back in the same box.

Example: A counter that changes

lamps = 3
print(lamps)
lamps = lamps + 2
print(lamps)

Output

3
5

Try this

  • Make a variable called age, store your age, and print it.
  • Store the number of pencils you own, give two away in code, and print what is left.
  • Try using a variable before you create it. What does Python say?

Practise it in Wonderwild

“Light up the workshop”

Mission 2 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+.

Try this mission free with Pip

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

Questions parents and kids ask

What names can I give a variable?+

Use letters, numbers and underscores, and start with a letter. No spaces, so write snack_count rather than snack count. Choose names that describe what the box holds.

Why is it called a variable?+

Because the value can vary. The name stays the same while what is stored inside can change as the program runs.

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