Updating and changing values in a variable
I can explain why a variable is used in a program.
Updating and changing values in a variable
I can explain why a variable is used in a program.
These resources will be removed by end of Summer Term 2025.
Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.
These resources were created for remote use during the pandemic and are not designed for classroom teaching.
Lesson details
Key learning points
- A program variable is a placeholder in memory for a single value.
- A variable must be named and hold data.
- 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...
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.
The starter quiz will activate and check your pupils' prior knowledge, with versions available both with and without answers in PDF format.
We use learning cycles to break down learning into key concepts or ideas linked to the learning outcome. Each learning cycle features explanations with checks for understanding and practice tasks with feedback. All of this is found in our slide decks, ready for you to download and edit. The practice tasks are also available as printable worksheets and some lessons have additional materials with extra material you might need for teaching the lesson.
The assessment exit quiz will test your pupils' understanding of the key learning points.
Our video is a tool for planning, showing how other teachers might teach the lesson, offering helpful tips, modelled explanations and inspiration for your own delivery in the classroom. Plus, you can set it as homework or revision for pupils and keep their learning on track by sharing an online pupil version of this lesson.
Explore more key stage 2 computing lessons from the Using variables in programming to develop a game unit, dive into the full primary computing curriculum, or learn more about lesson planning.
Equipment
Pupils will need access to a device with block-based programming software. Examples in this lesson use Scratch https://oak.link/scratch
Licence
Prior knowledge starter quiz
6 Questions
Q1.Match each example to the correct keyword:
name
value
change
variable
Q2.What is a variable in a computer program?
Q3.What is the data stored inside a variable called?
Q4.Put these actions in order for changing a variable’s value during a game:
Q5.What do we call the label given to a variable?
Q6.Why do programmers give variables names?
Assessment exit quiz
6 Questions
Q1.What is a variable in a computer program?
Q2.What does the value of a variable represent?
Q3.What must every variable have?
Q4.Put these steps in order for using a variable in a program:
Q5.Match each keyword to its meaning:
a named piece of data stored in memory
the data stored in a variable
to give a variable a starting value
to update the value in a program