New
New
Lesson 2 of 6
  • Year 6

Updating and changing values in a variable

I can explain why a variable is used in a program.

Lesson 2 of 6
New
New
  • Year 6

Updating and changing values in a variable

I can explain why a variable is used in a program.

These resources were made for remote use during the pandemic, not classroom teaching.

Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.

Lesson details

Key learning points

  1. A program variable is a placeholder in memory for a single value.
  2. A variable must be named and hold data.
  3. The value of a variable can be changed by running a program.

Keywords

  • Variable - a named piece of data stored in a computer’s memory which can be accessed and changed by a computer program

  • Change - to update the value of something in a program

  • Set - to give a variable a starting value in a program

  • Value - the data stored in a programming variable which can be used or changed

Common misconception

Why does the variable name matter? Can't I just call it "Number" or "Variable_A"?

You can call a variable anything you like but it's not very helpful for someone wanting to understand what your program does. The name of a variable should clearly identify what data it will hold as the program runs.


To help you plan your year 6 computing lesson on: Updating and changing values in a variable, download all teaching resources for free and adapt to suit your pupils' needs...

You need to know that a variable is a placeholder for a single value in the memory of a computer, and that all variables are uniquely named.
Teacher tip

Equipment

Pupils will need access to a device with block-based programming software. Examples in this lesson use Scratch https://oak.link/scratch

Licence

This content is © Oak National Academy Limited (2025), licensed on Open Government Licence version 3.0 except where otherwise stated. See Oak's terms & conditions (Collection 2).

Lesson video

Loading...

Prior knowledge starter quiz

Download quiz pdf

6 Questions

Q1.
Match each example to the correct keyword:

Correct Answer:“score” in a game,name

name

Correct Answer:10 points in a game,value

value

Correct Answer:changing your name from “Tom” to “Sam”,change

change

Correct Answer:a word or number stored in a program,variable

variable

Q2.
What is a variable in a computer program?

a type of sprite
the background of the stage
Correct answer: a named piece of data stored in memory
a sound effect

Q3.
What is the data stored inside a variable called?

Correct Answer: value

Q4.
Put these actions in order for changing a variable’s value during a game:

1 - player scores a point
2 - the program adds 1 to the score variable
3 - the new score is shown on the screen
4 - the player keeps playing

Q5.
What do we call the label given to a variable?

value
change
number
Correct answer: name

Q6.
Why do programmers give variables names?

Correct answer: so they know what the variable is for
to make the program longer
to change the background
to play music

Assessment exit quiz

Download quiz pdf

6 Questions

Q1.
What is a variable in a computer program?

a type of computer
Correct answer: a placeholder in memory for a single value
a sound effect
a background colour

Q2.
What does the value of a variable represent?

Correct answer: the data stored in the variable
the type of block
the name of the variable
the background image

Q3.
What must every variable have?

Correct answer: a name
a colour
a sound
a sprite

Q4.
Put these steps in order for using a variable in a program:

1 - decide what data you need to store
2 - create and name the variable
3 - set its starting value
4 - change its value as the program runs

Q5.
Match each keyword to its meaning:

Correct Answer:variable,a named piece of data stored in memory

a named piece of data stored in memory

Correct Answer:value,the data stored in a variable

the data stored in a variable

Correct Answer:set,to give a variable a starting value

to give a variable a starting value

Correct Answer:change,to update the value in a program

to update the value in a program

Q6.
What happens to a variable’s name when the program runs and the data changes?

Correct answer: It stays the same.
It disappears.
It becomes a sprite.
It changes to show the new data.