Variable
Variable
A "box" in a program that temporarily stores data such as values or characters.
In Simple Terms
A variable is a named box used to hold data within a program. For example, in a game you might store a player's name, or calculate a score and show it on screen—numbers and text get placed into this "variable" box along the way. Behind the scenes of smartphone apps, websites, and just about every other kind of program, variables play a key role in temporarily holding onto data.
Behind the Name
The word "variable" combines "vary," meaning to change, with the suffix "-able," meaning capable of. Together they describe something whose value can be changed. In programming, this word is used as the name for the "box" that holds data.
Take a Closer Look!
A variable is a mechanism in programming that works like a box for temporarily storing data such as numbers or characters.
A program can freely swap out what's inside this box, or take the contents back out later to use them.
Think of it as a notepad whose contents can be rewritten.
It's similar to the x or y you might remember from middle school math, but in programming, a variable can hold not just numbers but also text, image data, and more.
You can give each variable any name you like, and calling that name in your code lets you retrieve the data inside it whenever you need it.
For example, a smartphone's contacts app temporarily stores each registered name and phone number in its own variable before displaying it on screen.
In a game's score display, the contents of a variable called score get rewritten every time the points change.
In this way, variables are one of the most fundamental building blocks for handling data in any app or system.