Primary Wiki · Computing · KS2
What is a variable in coding?
A variable is like a labelled box that a program uses to store a piece of information, such as a score or a name. The value inside can change as the program runs.
An example
In a game, you might have a variable called "score". It starts at 0, and every time the player collects a coin, the program adds 1 to it. The label stays the same but the value inside changes.
An everyday comparison
Think of a variable like a named jar. The label on the jar (the name) stays the same, but you can change what is inside it (the value).
Where this sits in the curriculum
Variables are introduced in KS2 computing, often using Scratch, as pupils write and debug their own programs.