Variables in a program

Ages 9 to 12 Read alone or together · about 25 minutes

Read together

A variable is a named box that holds a value. The value can change as the program runs.

A score in a game is a variable.

Do it

  1. Play a paper game: a cup labelled score holds tokens. Each point, add one.
  2. Write the rules as steps: start score at 0; if you hit the target, add 1.
  3. Change the rule: add 2 for a bonus. Predict the score after five rounds.
  4. If you have a block coding tool with a grown-up, make a score variable there.

Talk about it

For the grown-up

Variables are central to programming and to algebra. This lesson works with paper. If your child uses a coding site, choose one with no accounts, ads or chat, and sit with them.

← Previous lesson Next lesson →

Where this comes from
  • K-12 Computer Science Framework Steering Committee, K-12 Computer Science Framework (2016), concept: algorithms and programming (variables)
  • Knuth, D. E., The Art of Computer Programming, Volume 1 (Addison-Wesley, 1968)

Written with AI assistance and checked against the sources listed. Please read it before sharing it with a child.