Variables in a program
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
- Play a paper game: a cup labelled score holds tokens. Each point, add one.
- Write the rules as steps: start score at 0; if you hit the target, add 1.
- Change the rule: add 2 for a bonus. Predict the score after five rounds.
- If you have a block coding tool with a grown-up, make a score variable there.
Talk about it
- What is the variable's name?
- What is its value now?
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.