Using Variables to Store Scores and Information

Using Variables in Programs

1 / 28
next
Slide 1: Slide
New lesson editorComputingPrimary Education

This lesson contains 28 slides, with interactive quizzes and text slides.

time-iconLesson duration is: 50 min
Report this lesson

Items in this lesson

Using Variables in Programs

This title opens the lesson with the broad idea that programs can store changing information. Keep the opening concrete by mentioning familiar examples such as scores, names and lives in games.

Learning goal

I can use variables to store and update scores and information in a program.

This item has no instructions

What kinds of things could a program remember for you?

Use this as prior-knowledge activation after the learning goal. Encourage short answers such as score, name, time, lives, points or level, then link these ideas to variables.

Lesson introduction

This KS2 computing lesson explores Using Variables to Store Scores and Information. Pupils create and update variables in a program and explain how stored values can affect what happens on screen. It is suitable for classroom teaching, independent practice or a clear recap of the topic.

This slide contains the required wording verbatim. Do not paraphrase it when presenting if the wording needs to be preserved exactly.

What is a variable?

A variable is a named place in a program where information is stored.


It can hold a value such as:

  • a score

  • a name

  • a number of lives

  • a timer

Emphasise that a variable is not the value itself. It is the labelled place that stores the value.

Why programs use variables

Programs use variables when information needs to change or be remembered.


Examples:

  • a game score goes up

  • a player's name is saved

  • a countdown changes each second

  • a quiz keeps track of points

Link this to pupils' everyday experience of games and apps. The key idea is that variables are useful because the value does not stay fixed.

A variable storing a score

A score variable might start at 0.


When a player earns points, the program changes the value.


Example:

  • start score = 0

  • earn 1 point

  • score = 1

Keep this very concrete. You can act out the score changing on the board to show that the variable name stays the same while the value changes.

Creating a variable

When you create a variable, you give it:

  • a name

  • a starting value


Good variable names help us understand the program, such as:

  • `score`

  • `playerName`

  • `lives`

  • `timeLeft`

Point out that clear names make code easier to read. Avoid discussing programming language differences unless pupils already know a specific environment such as Scratch.

What is a variable?

A

A stored place

B

A game screen

C

A code bug

D

A fixed rule

Checks the key idea from slides 3 to 6: a variable is a named place in a program where information is stored. Distractors reflect likely confusion with other computing words.

Complete the variable explanation

A variable is a named place in a program where information is stored. It can hold a score or a name. When you create one, it needs a clear name and a starting value.

variable
score
name
screen
button
message
player

This anchors the core vocabulary from the first teaching block. It also reinforces that examples of stored values include both scores and names.

Why is score a better variable name than thing?

Expected answer elements: good answers should mention that the name tells us what the variable stores and makes the program easier to understand or read. Accept examples such as score, lives or playerName.

Updating a variable

A variable can be updated while the program runs.


For example:

  • `score` starts at 0

  • player gets an answer right

  • program adds 1

  • `score` becomes 1

  • after another point, `score` becomes 2

This is the key process slide: the value changes during the program. If useful, model it step by step with counters or tally marks.

Variables can store information too

Variables do not only store numbers.


They can also store information such as:

  • a player's name

  • a team colour

  • a message

  • an answer choice

Make the distinction between numeric data and text simple: both can be stored, and both can be used later by the program.

Using a name variable

A program might ask for a name and store it in `playerName`.


Then it can show messages such as:

  • `Hello, Aisha!`

  • `Well done, Aisha!`


The program feels more personal because it uses stored information.

Use a few pupil names as examples so they can see how the same program changes its output depending on the stored value.

How values affect the screen

The value inside a variable can change what happens on screen.


Examples:

  • `score` decides what number is shown

  • `lives` decides whether the game continues

  • `playerName` changes the greeting

  • `timeLeft` changes the countdown display

This slide answers the lesson's central idea: stored values are used by the program to decide what to show or do.

When a value changes the result

Sometimes a program checks a variable before choosing what happens next.


Example:

  • if `lives` is more than 0, keep playing

  • if `lives` is 0, show Game Over

Avoid heavy terminology such as conditionals unless the class already knows it. The important point is that the variable's value can control the outcome.

If score starts at 0 and gains 1 twice, what is score now?

A

1

B

0

C

3

D

2

Checks understanding of updating a variable from slide 7.

Fill in the program steps

A program might ask for a player's name and store it in playerName. Later, the stored value can change the greeting on screen, such as Hello, Aisha!

name
playerName
greeting
score
lives
timer
points

This uses the exact lesson context from slides 8 to 11: storing text information and using it to change what appears on screen.

What should happen if lives is 0?

A

Add a point

B

Keep playing

C

Show Game Over

D

Ask for a name

Checks the decision-making example on slide 11, where the variable value controls the outcome.

Following a simple program

`score` = 0 → player answers correctly → add 1 → show new score


This means:

  • the variable starts with a value

  • an event happens

  • the value is updated

  • the screen shows the new value

The arrow chain is useful here because the whole slide is about the sequence. Read it aloud slowly and trace the change.

Useful variable examples

In KS2 programs, variables might be used for:

  • points in a quiz

  • a player's name in a story

  • lives in a game

  • time left in a challenge

  • number of collected objects

This slide broadens the concept without adding new mechanisms. Keep examples rooted in simple classroom programming projects.

Which variable would be most useful in your own simple project?

1

score

2

playerName

3

lives

4

timeLeft

This item has no instructions

Put the sequence together

In a simple program, score starts at 0. Then the player answers correctly, the program adds 1, and the screen shows the new score.

score
1
score
name
2
lives
timeLeft

This is the application check-in for slides 12 and 13. It follows the taught sequence: starting value, event, update, screen output.

Name one variable you would use in your own program.

Expected answer elements: pupils should name a sensible variable such as score, lives, playerName or timeLeft, and say what information it would store in their project. This can support the application task and differentiation by allowing varied project ideas.

What is one thing you learned about variables today?

Reflection only. Invite short answers about the main learning from the lesson.

What helped you understand variables best?

Reflection only. Use answers to see which explanation, example or model helped most.

Which part of this lesson felt trickiest?

Reflection only. This helps identify misconceptions or parts to revisit, such as starting values, updating or screen output.

Glossary

More terms

Key terms

variable - a named place in a program where a value is stored

value - the information kept inside a variable

score - the points earned in a game or quiz

update - to change a stored value in a program

information - data such as words or numbers used by a program

starting value - the first value given to a variable

screen output - what the program shows on screen

This item has no instructions