🤖 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.

  1. Warm-up3 min
  2. Warm-up games5 min
  3. Make a box with =9 min
  4. Change what's in the box9 min
  5. f-strings: fill in the blanks9 min
  6. Game score keeper7 min
  7. Silly story machine7 min
  8. Swap the cups5 min
  9. Quiz5 min
  10. 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.

More warm-ups for every class →

🎮 Warm-up games · 5 quick games

Play with Bolt the robot

Five minutes with Bolt the robot. Vote, say why, then show the answer.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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 =

Listen to this part

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

  1. name = "Bolt"

    Run it. Nothing prints, but look under the code: a box called name! Text still needs quotes.

  2. score = 10

    Another box. Numbers don't need quotes.

  3. print(name)

    No quotes around name, so Python looks in the box.

  4. print(score)

    Ask: what will this show?

  5. print("score")

    With quotes it's just the word. Spot the difference.

Type here

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Example: run it, then change it

▶ Output

tiger
4
A tiger has 4 legs

📦 Memory boxes

pet'tiger'strlegs4int

Change 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.

Warm-up

1.1 Make a box called age holding 10, then print it.

Task 1.1

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Model answer (for the teacher)
age = 10
print(age)
Warm-up

1.2 Make a box called colour holding the word blue, then print it.

Task 1.2

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Model answer (for the teacher)
colour = "blue"
print(colour)
Core

1.3 The boxes are ready. Print exactly: Mia is 11, using the boxes and a comma.

Task 1.3

▶ Output

(nothing is printed)

📦 Memory boxes

name'Mia'strage11int
Model answer (for the teacher)
name = "Mia"
age = 11
print(name, "is", age)
Core

1.4 width is 6 and height is 4. Make a box area holding width * height and print it.

Task 1.4

▶ Output

(nothing is printed)

📦 Memory boxes

width6intheight4int
Model answer (for the teacher)
width = 6
height = 4
area = width * height
print(area)
Stretch 🔥

1.5 price is 25 and count is 8. Print exactly: Total: 200 rupees. It must still work if the boxes change.

Task 1.5

▶ Output

(nothing is printed)

📦 Memory boxes

price25intcount8int
Model 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

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try