# What is a variable in computing?

Find out how variables are used in computing and how they are introduced in the KS2 classroom in our parents' guide to variables.

## What is a variable in computing?

A variable is something that can be changed.

In computer programming we use variables to store information that might change and can be used later in our program.

For example, in a game a variable could be the current score of the player; we would add 1 to the variable whenever the player gained a point. In a banking system, a variable could be used to store the balance of an account. When the customer makes a withdrawal the amount in this variable will be reduced by the withdrawal amount.

## Variables in KS1 computing

Generally variables are considered a fairly advanced concept in computer science so unless your child is writing programs using a visual programming language such as Scratch in KS1 then it is unlikely that they will be taught the principles of variables so early on.

## Variables in KS2 computing

In KS2 your child will start using visual programming languages, allowing them to build basic computer programs and games by connecting building blocks together into a program.

Visual programming languages are an excellent way to get started programming as they do not require anywhere near as much debugging as a textual programming language.

Variables will be introduced in KS2 most likely using a visual programming language called Scratch.

Scratch is an excellent tool to teach programming as it allows your child to use very advanced programming techniques in a very simple and easy-to-use format. In Scratch a variable can be created that stores any information you would like about the game you are building.

In the following example we show what real Scratch blocks look like when building a simple game that allows a player to move right and left, avoiding an enemy. Here's what some of the blocks mean:

Now let’s look at a piece of code that uses Scratch blocks to build our game:

The above code is a fantastic example of how a variable is used in real-life coding and this is the sort of activity your child may be doing in KS2 in order to learn about variables. At any point in the game you can tell how many times the player has died by seeing what the value of deaths is; clicking the green flag resets the game and resets our number of deaths back to 0.

## Variables in primary school: what your child learns year-by-year

Please note that the following guidelines for what is taught in each primary year is for guidance only and may not be representative of the way computing is taught at your child’s school.

Year 3
Students will be introduced to the idea of variables with reference to real-world objects such as a glass that could hold orange juice or apple juice.

Year 4
The idea of variables will be applied to a visual programming language and students will learn to store basic information such as a game score in a variable.

Year 5 and Year 6
Variables will be linked to other ideas such as loops and conditions (we can run a command if a variable is equal to something else, or stop running a loop once a variable has reached a certain value).

• FREE articles & expert information
• FREE resources & activities
• FREE homework help
By proceeding you agree to our terms and conditions. For information on how we use your data, see our privacy policy. You will receive emails from us but can opt out at any time.