Computing KS2: Variables

This short film explores how computers use variables to store things that change, like names, numbers and scores.

The familiar example of a quiz is used to show how a changing score could be stored in as counters in a box, and this idea is then used to explain how a computer variable stores the changing value in a computer program ready for the program to use.

The film then looks at the program commands needed to keep score in the computer quiz, and how this variable can be used to trigger actions like showing a winner banner when a specific score is reached.

Finally, it looks at how variables can be used to ask questions like, ‘what is your name?’, and then use the answer stored as a variable to personalise the quiz.

This short film is from the BBC Teach series, Cracking Computing.

Teaching Notes

A good place to start with variables is to explore the idea of a variable box to keep a piece of changing information in, and using a real container to develop the concept. The variable will need a name such as score, date, name, temperature, etc.

Simple computer quizzes are another good way to introduce variables, as a changing score is easily understood.

Computer systems with sensors like central heating systems, or street lamps with light sensors are useful real-world examples where the use of a variable (temperature and light level) is measured and recorded by a sensor.

Flow diagrams can help pupils to understand the process and where the variable fits in. For example:
- Variable name is 'temperature' - get reading every 10 seconds from external thermometer - When temperature is greater than 23 degrees, then switch off heating - When temperature is less than 23 degrees, then switch on heating.

Other subjects

Science / Geography: Work on weather and weather stations can include using automated weather data systems that will collect a range of data and have a range of variables to explore.

Curriculum Notes

This short film is suitable for teaching:

  • KS2 computing curriculum in England
  • Technologies curriculum area at 2nd Level in Scotland
  • KS2 digital competence framework in Wales
  • KS2 using ICT cross-curricular skill in Northern Ireland

More from Cracking Computing

Computer networks
Creating with computing
Input and output
Logical reasoning
Search technologies
Working with data