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 lives at the end?
- 6
- 5
- 7
- 1
Show answer
Answer: 6. lives starts at 1. 1 + 2 = 3, 3 + 3 = 6. So lives ends at 6.
2. What is gems at the end?
Show answer
Answer: 6. gems starts at 0. 0 + 4 = 4, 4 + 2 = 6. So gems ends at 6.
3. What is gems at the end?
- 2
- 3
- 0
- 1
Show answer
Answer: 1. gems starts at 3. 3 − 2 = 1. So gems ends at 1.
4. Number or text variable?
- name = "Mia"
- age = 9
- score = 120
- colour = "blue"
- lives = 3
Baskets: Number · Text
Show answer
Answer: Number: age = 9, lives = 3, score = 120 · Text: colour = "blue", name = "Mia". Text goes in quotation marks.
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.