🤖 Python Grade 5 · session 3 of 12 · 60 minutes · 🎁 free with an account
Variables: Bolt's labelled boxes
Bolt has a shelf of labelled boxes. Put a number or a name in a box, change it, and use it again and again. This is how every game keeps your score.
A complete lesson · 60 minutes
Teach it, see it, practise it, all on this page.
Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.
- Warm-up3 min
- Warm-up games5 min
- Make a box with =9 min
- Change what's in the box9 min
- f-strings: fill in the blanks9 min
- Game score keeper7 min
- Silly story machine7 min
- Swap the cups5 min
- Quiz5 min
- Set the after-class project1 min
By the end you can
- Make a variable with =
- Change a variable and see the new value
- Use += to add to a score
- Print sentences with f-strings
Before you start
- Lesson 1: print()
- Lesson 2: sums in Python
Have ready
- This page
- Sticky notes or paper boxes (optional)
Grade 5 · ages 10 and 11 · no experience needed
Warm-up · think first
A box is labelled coins. It holds 5. You throw that away and put in 9. What is in the box now?
Show the answer
9. A box holds one thing at a time, and the newest thing replaces the old one.
Teacher tip: Use a real box or a cup with a sticky note.
🎮 Warm-up games · 5 quick games
Play with Bolt the robot
Five minutes with Bolt the robot. Vote, say why, then show the answer.
- Which is the best label for a box holding your score? (score · x · my score · 2score)
Answer: score is best: it says what's inside. A label with spaces won't work in Python, and x tells you nothing. - Would you rather have coins = 10 then coins + 5, or coins = 20 then coins - 3? (10, then add 5 · 20, then take 3)
Answer: Start with 20 and take 3: that leaves 17, which beats 15. - A variable keeps its first value for ever. (Always · Sometimes · Never)
Answer: Never. You can change it whenever you like. Only the newest value stays. - lives = 3, then lives = lives - 1, then lives = lives - 1. How many lives are left?
Answer: 1. Take one away, then take one away again. - What does a game need to remember while you play?
Answer: Score, lives, level, your name, the time. Each of these is a variable!
Part 1 of 3 · learn, see, practise
Make a box with =
This is my shelf of boxes. score = 10 means: make a box, label it score and put 10 inside. Watch the memory boxes under the code!
A variable is a labelled box. score = 10 puts 10 in a box called score.
No quotes around the label when you use it: print(score) shows 10, and print("score") shows the word.
Labels use small letters and no spaces: my_score is fine, my score is not.
🧑🏫 Teacher: type this live with the class
Fill Bolt's boxes
name = "Bolt"Run it. Nothing prints, but look under the code: a box called name! Text still needs quotes.
score = 10Another box. Numbers don't need quotes.
print(name)No quotes around name, so Python looks in the box.
print(score)Ask: what will this show?
print("score")With quotes it's just the word. Spot the difference.
▶ Output
(nothing is printed)
📦 Memory boxes
▶ Output
tiger 4 A tiger has 4 legs
📦 Memory boxes
'tiger'strlegs4intChange the first two lines to your own pet. Only two changes update the whole sentence!
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 Make a box called age holding 10, then print it.
▶ Output
(nothing is printed)
📦 Memory boxes
Model answer (for the teacher)
age = 10
print(age)1.2 Make a box called colour holding the word blue, then print it.
▶ Output
(nothing is printed)
📦 Memory boxes
Model answer (for the teacher)
colour = "blue"
print(colour)1.3 The boxes are ready. Print exactly: Mia is 11, using the boxes and a comma.
▶ Output
(nothing is printed)
📦 Memory boxes
'Mia'strage11intModel answer (for the teacher)
name = "Mia"
age = 11
print(name, "is", age)1.4 width is 6 and height is 4. Make a box area holding width * height and print it.
▶ Output
(nothing is printed)
📦 Memory boxes
6intheight4intModel answer (for the teacher)
width = 6
height = 4
area = width * height
print(area)1.5 price is 25 and count is 8. Print exactly: Total: 200 rupees. It must still work if the boxes change.
▶ Output
(nothing is printed)
📦 Memory boxes
25intcount8intModel answer (for the teacher)
price = 25
count = 8
print("Total:", price * count, "rupees")🎁 Free for a year
Make a free account to open the rest of this lesson
Every new account opens every lesson of every course free for a whole year: no payment, no card, nothing to cancel.
Unlocking the rest of this lesson gives you:
- Part 2: Change what's in the box, with practice at three levels
- Part 3: f-strings: fill in the blanks, with practice at three levels
- Class activity 1: Game score keeper
- Class activity 2: Silly story machine
- Class activity 3: Swap the cups
- A 8-question quiz
- After-class project: My game character card
- Homework and a printable practice sheet with answers
- Teach mode and the minute-by-minute teacher's plan
It takes a minute. Anyone under 13 signs up with a parent. The first 2 lessons of every course, every game and all maths practice stay free.
FAQ
Variables: Bolt's labelled boxes: questions
What is a variable in simple words?
A labelled box that remembers something for your program, like a score or a name.
What is an f-string?
A sentence with blanks. Put f before the quotes, and Python fills in anything inside curly brackets.
Why does my program say NameError?
It means Python can't find a box with that label. Check the spelling, and make the box above the line that uses it.
Start a conversation
Want a teacher to take this class?
Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian