How to teach working with variables in Key Stage 2 Computing

Author: Estelle Ashman, Curriculum Content Developer

This months National Curriculum strand: working with variables

This month our 'How do I teach...' blog will focus on ideas around how you could teach students to work with variables.

Common misconceptions

  1. This strand requires programming. This is another strand that can be introduced to students using an unplugged activity. Students will also come across variables in KS2 Science so this can be an opportunity to get your learners thinking about variables - ask them to identify all the variables in the instructions for an experiment or this could be an opportunity for students to do some cooking and identify the variables in a recipe. You could even introduce the concept of variables through spreadsheet modelling using a recipe and set the workbook up in such a way that changing the number of people the recipe is for automatically changes the measurements of the ingredients.
  2. Primary students cannot use text based programming languages. Upper KS2 students can benefit from learning how to use variables in text based programming languages such as Python as sometimes the added visual elements of programming languages such as Scratch can add an extra layer of difficulty that some learners may find confusing. Alternatively, introducing variables with a definite visual element (such as drawing shapes of different sizes) can be a good way of helping students to understand that a variable can change while the program is running as they can see the output clearly changing, for example. a program which draws increasing sized circles using Python Turtle. Introducing variables can also be a good opportunity to have students compare the process in a visual programming language such as Scratch and a text based language such as Python.
  3. Game development is too complex for primary students. Using a scenario that students have a good understanding of is brilliant for introducing new concepts. Most students will understand the concept of a scoring system and creating a simple PacMan style game can be a good way of introducing variables. A part-baked game, where most of the game is already developed and learners only need to finish off one specific element, can be a good option as it means you can deep dive into one element while using a more complex game as students wont actually be programming the main game concept. A scoring system can also be easily acted out as an unplugged activity - set up a maze in your classroom using masking tape on the floor, place objects for PacMan to collect and have a student add 1 to the score each time on a mini white board. This can also be a good introduction to trace tables (where you keep track of the value of a variable as each line of a program is run).

What resources do Digital Schoolhouse have to support the teaching of this strand?


  1. Big Data. In this workshop your learners will design a Python quiz program which uses variables and explore how and why companies collect data from users of social media.
  2. Maths Quiz. In this workshop design a maths quiz that uses variables in Python.
  3. Surprise Stories. In this workshop find out how to create a interactive story which uses variables and randomly selects words.

Playful Computing Activities

Accidental Adventures. This activity is a brilliant way of introducing students to the concept of variables while reinforcing English concepts. Learners identify variables in a simple story and label what type of word they are (noun, verb etc.). They then have to list six words for each of the different word types and use a die to randomly select what word will be used in the story. This can be a nice activity to use as an introduction to the Surprise Stories workshop.

And there you have it, three workshop suggestions and a playful computing activity to help you deliver the use sequence, selection, and repetition in programs strand from the Key Stage 2 National Curriculum for Computing.

If you have any comments or queries about these resources, I'd love to hear from you - drop me an email at

If you're not sure where these activities could fit into your curriculum or would like to see the resources in action first? You can book a free workshop with your local Schoolhouse.