A variable is a named box that stores a value — like a score in a game. Programs set variables and then change them as things happen.
What your child will learn
- Understand that a variable stores a value
- Work out a variable’s value after it is changed
- Follow changes made inside a loop
Keeping score
Every game children play has variables: score, lives, coins. Variable Valley uses Scratch-style blocks such as “set score to 3” and “change score by 2”, so children can trace the value step by step, just as they will in real coding apps.
Example questions
Here are a few questions like the ones in the first quest. Can you solve them?
1. What is score at the end?
- 0
- 3
- 1
- 5
Show answer
Answer: 0. score starts at 3. 3 − 1 = 2, 2 − 2 = 0. So score ends at 0.
2. What is coins at the end?
- 4
- 1
- 3
- 5
Show answer
Answer: 4. coins starts at 1. 1 − 1 = 0, 0 + 4 = 4. So coins ends at 4.
3. What is score at the end?
Show answer
Answer: 5. score starts at 5. 5 − 5 = 0, 0 + 5 = 5. So score ends at 5.
Tips for grown-ups
- Keep score in a board game and talk about it as a variable that changes.
- Use a jar of counters as a “variable” and follow instructions to change it.