Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Updating and changing values in a variable

      Lesson details

      Learning outcome

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

      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.

      Teacher tip

      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.

      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 (2026), 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

      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

      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.

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