Coding Education

5 min read

What Is a Variable in Programming?

Hafiz Rahman

Hafiz Rahman

Lead Coding Instructor at Algonova Malaysia

What Is a Variable in Programming?

A variable in programming is a named container that stores a piece of data — like a number, a word, or a true/false value — so a program can use it and change it later. The name is a label you choose; the value is what sits inside, and it can vary while the program runs — that is exactly why it is called a "variable". This is the programming meaning, not the statistics one.

Think of a variable as a labelled box. You write a name on the box (score), drop something inside (0), and the computer remembers it. Later you can look inside, swap the contents, or do maths with them.

How a Variable Works

In Scratch, a child makes a variable called score and sets it to 0. Each time the player catches a star, a change score by 1 block runs, so the same box now holds 1, then 2, then 3 — the name stays the same while the value changes.

In Python, the same idea is just two lines: score = 0 creates the variable and stores 0, then score = score + 1 reads the current value, adds one, and saves the result back under the same name. Variables commonly hold numbers (10), text called strings ("Amir"), and true/false values called booleans.

Why Variables Matter for Kids

Variables are one of the first big ideas in coding — almost every game, quiz or app tracks something (a score, a name, a level) in a variable. Getting comfortable with them early makes the jump from drag-and-drop blocks to real text code far smoother, a core step in Algonova's coding classes for kids. For a gentle starting point, see what coding is for kids.

Curious to see it click? Book a free trial class and watch your child build their very first score counter.