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

      Lesson details

      Learning outcome

      I can use variables to store values and trace how they change in a program.

      Key learning points

      1. A variable is used to store a value in a program.
      2. A variable can be updated with a new value which replaces the initial value it was assigned.
      3. The value of a variable can be tracked throughout 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

      • Value - the data a variable holds at a particular time

      • Trace - to track the value a variable holds at any time during a program

      Common misconception

      The value a variable holds cannot be updated and a computer remembers the previous values of variables.

      A variable can be updated during a program. Once the value of a variable is updated in a program, the previous value is overwritten.

      Teacher tip

      The story has been modelled with examples in the slide deck. If you would prefer you could note down your class' responses and use these variables instead.

      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.
      True or false? A subroutine can only be called once in a program.

      true
      Correct answer: false

      Q2.
      Which word describes the order in which commands are run during a program?

      Correct answer: sequence
      algorithm
      code

      Q3.
      What colour is the variables block in Scratch?

      Correct answer: orange
      blue
      purple
      green

      Q4.
      What types of data can a variable hold?

      images
      Correct answer: text
      Correct answer: numbers

      Q5.
      In a bat and ball game, which of these parts of the game would be stored using a variable?

      Correct answer: points scored
      movement of the sprite
      Correct answer: lives lost
      Correct answer: time left
      appearance of the stage

      Q6.
      When is the value of a variable usually set?

      Correct answer: at the beginning of a program
      throughout the running of a program
      at the end of a program
      when triggered by an event

      4 Questions

      Q1.
      How many values can a variable hold at any one time?

      none
      Correct answer: one
      two
      three

      Q2.
      When a variable is changed, what happens to the value?

      Correct answer: It is replaced by a new value.
      It is joined by the new value.
      It is added to the new value.

      Q3.
      What is the name of the built-in variable in Scratch that holds user input?

      Correct Answer: answer

      Q4.
      Which block can be used to combine a variable and a message in Scratch?

      Correct answer: join
      combine
      add

      To help you plan your 7 computing lesson on: Program variables, download all teaching resources for free and adapt to suit your pupils' needs...