Skip main navigation

How to use real-world examples to teach children what variables are

Using real-world examples allows computer learners to build an understanding of concepts and ideas that they are already familiar with
2.5
A variable is something that varies, changes, or can be changed. For example, people’s names are something that varies.
15
The weather changes every day.
20.6
The scoreboard in a football match can be changed to reflect the score.
27.5
These examples are variables but in different ways. Names vary from person to person, but those names don’t change very often. The weather changes continually over time. Scores in a football match change, but only when a specific event occurs– a goal is scored. Computer programs use variables in similar ways. A program may ask a user to enter their name. This value is then stored as a variable. The program can then use that name variable to personalise the user experience. A program could store the reading from a temperature sensor as a variable value, and then use that value to control the heating system. Variables are also used in computer games to store scores, lives, or time remaining.
84.2
These examples mirror the earlier real-life scenarios. Getting your pupils to think about variables in both real-life and programming contexts can help them to connect the abstract concept of variables to more relatable and memorable examples. Can you think of three real-life variables? Are they things that vary, change, or can be changed? Is it possible for a variable to fit more than one category? What programs or apps do you use that utilise variables? What causes those variables to change? Share your thoughts in the comments section below.

Using real-world examples works well with learners, because it allows them to build an understanding of concepts and ideas that they are already familiar with. In the same way, we can introduce the concept of variables in the real world.

Something can be described as variable if it varies, changes, or can be changed.

1 Something that varies

People’s names are an example of something that varies, for example my name is likely to be different to your name.Animation of a person saying hello to several different people. Each time they say "Hello..." which doesn't change, but a new name appears for each new person.

2 Something that changes

The weather is an example of something that changes, for example today it is sunny and yesterday it rained.

An animation of a woman looking at the weather through a window. The weather changes between the sun in a clear sky, the sun partially hidden behind a cloud, and a raining cloud. While the weather is sunny the woman is happy, but she is sad when it is raining.3 Something that can be changed

The scoreboard in a football match can be changed to reflect the current score.

A football scoreboard reading Liverpool 0 - 0 Manchester, then changing to Liverpool 0 - 1 ManchesterEach of these examples can be described as variable, but in different ways and for different reasons. Different people have different names, but those names don’t change often or at all. The weather changes continually and can change over a few hours or even less. Scores in a football match change only when a particular event occurs: each time a goal is scored. Computer programmes also use variables in different ways, similar to these.

Variables in computer programmes

Here are some examples of how variables are used in computers programmes.

A programme may ask a user to enter their name. This value is then stored as a variable. The programme can then use that name to personalise the experience. For example, instead of asking: “How are you feeling?”, the programme could say, “Hi John, how are you feeling?”. When someone else uses the program, the variable value can be set to the new user’s name.

A reading can be taken using a temperature sensor and temporarily stored by the programme as a variable value. This variable value can then be displayed on a device and/or used to control a system, such as a heating system.

Variable values

Variable values are also used in games. They can have a variety of uses, for example to store scores, lives, time elapsed or time remaining.

These three examples mirror the real-life examples above. The name varies, the temperature changes, and the player’s score in a game can be changed. It can be useful for you and your learners to think about variables in both real-life and programming contexts to help link the abstract idea of a variable to more concrete examples.

Try this

Think of three real-life variables:

  • Are they things that vary, that change, or that can be changed?
  • Is it possible for one variable to fit several of these categories?

Reflect on programmes or apps that you have used recently:

  • Where have you seen variable values used?
  • What causes those values to change?
This article is from the free online

Teaching Programming to 5- to 11-year-olds

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education