Offline activities · Quest 5

Variable boxes

Turn cups or envelopes into variables and watch their values change.

15 minutes

You will need

  • Three cups or envelopes
  • Sticky notes or paper slips
  • A pen

What to do

  1. Label the cups score, lives and name.
  2. Put a slip in each: score = 0, lives = 3, name = a made-up hero name.
  3. A helper reads orders such as “score = score + 5” and you change the slip.
  4. Try “lives = lives - 1” three times. What happens at 0?
  5. Write your own three orders and swap with the helper.

Talk about it

  • Why does the old value disappear?
  • When would a game need a lives variable?

See the book Code Quest with Python →