Coding Education

4 min read

What Is a Variable in Programming: Definition & Examples

Published: 10.07.2026·Updated: 10.07.2026
Bayu Nugraha

Bayu Nugraha

Children's Coding Specialist

What Is a Variable in Programming: Definition & Examples

In programming, a variable is a named container that stores data, and the value inside it can change while the program runs. Like a labeled box, you can put a number or text inside, read it back later, or replace it with a new value at any time.

How a Variable Works

Every variable has a name and a value. A programmer gives the variable a name and fills it with a value; the computer keeps that value in memory and can read it back whenever it is needed. Imagine a simple game: you create a variable called score and set it to 0 when the game starts. Each time the player collects a coin, the program runs score = score + 1, so the value changes from 0 to 1, 2, 3, and so on. In Scratch you do this with the "change score by 1" block; in Python it is a single line, score = score + 1. The stored value can be a number (a score of 10), text (a player name "Budi"), or a true/false value. The same variable can hold thousands of different values across one game.

Why It Matters for Kids

Understanding variables is the first step in thinking like a programmer: breaking a problem into data that can be stored, read, and changed. The concept appears in almost every programming language, from Scratch to Python, so once a child masters it, they can start building their own games, animations, and apps. In the Algonova coding course, kids learn variables through real projects they can play right away, not by memorizing terms.

Want your child to try building their own score game? Join a free coding class and see how variables work firsthand.