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 choose how to improve a game by using variables.

      Key learning points

      1. Variables can be updated at specific points in a program.
      2. An event in a program can be used to set a variable.
      3. A program can use the value of a variable.

      Keywords

      • Score - a named value which will track player points

      • Selection - part of a program where, if a condition is met, then a set of commands is run

      • Operator - a symbol used to compare values

      Common misconception

      I put the "change score by" block in my code, but the score isn't changing when I expect it to.

      The location of your "change score by" block dramatically affects when and how often the score changes.

      Teacher tip

      You will need to have an understanding of variables. The concept of variables has been developed in the prior lessons in this unit.

      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.
      What is the name for a space in memory that stores a single value in a program?

      Correct Answer: variable, a variable

      Q2.
      What must every variable have?

      a picture
      a sound
      a colour
      Correct answer: a unique name

      Q3.
      What does it mean to "set" a variable in a program?

      Correct answer: to give it a starting value
      to delete the variable
      to make it colourful
      to move a sprite

      Q4.
      What can the value of a variable do when a program runs?

      stay the same forever
      only be a colour
      Correct answer: change as the program runs
      only be a sound

      Q5.
      Put these steps in order for using a variable in a game:

      1 - decide what information you want to store
      2 - create and name the variable
      3 - set its starting value
      4 - change its value as the game runs

      Q6.
      Match each example to the correct keyword:

      Correct Answer:“score” in a game,variable

      variable

      Correct Answer:10 points in a game,value

      value

      Correct Answer:giving the score a starting value of 0,set

      set

      Correct Answer:increasing the score by 1,change

      change

      6 Questions

      Q1.
      What does "selection" mean in a program?

      choosing which colour to use
      Correct answer: running a set of commands only if a condition is met
      playing music
      drawing a picture

      Q2.
      What is the operator used in programming to compare two values and check if the initial value is less than the following one?

      Correct Answer: <

      Q3.
      What is the main job of an event in a program?

      Correct answer: to set a variable or trigger an action when something happens
      to change the background colour
      to play music
      to end the game

      Q4.
      Match each example to the correct keyword:

      Correct Answer:operator,checking whether the score is greater than 10

      checking whether the score is greater than 10

      Correct Answer:score,increasing the score when a coin is collected

      increasing the score when a coin is collected

      Correct Answer:selection,running code only when the score is high enough

      running code only when the score is high enough

      Correct Answer:event,player presses the space bar to jump

      player presses the space bar to jump

      Q5.
      Put these actions in order for using selection with a variable in a game:

      1 - the program uses an operator to compare the variable to a target value
      2 - if the condition is met, a set of commands is run
      3 - if the condition is not met, nothing happens or a different action runs

      Q6.
      Which statement about changing a score variable is wrong?

      the location of the block affects when the score changes
      the score only changes if the code tells it to
      events can be used to set or change the score
      Correct answer: the "change score by" block always works, no matter where it is in the code

      To help you plan your 6 computing lesson on: Improving a game, download all teaching resources for free and adapt to suit your pupils' needs...