Variable

Also known as: named storage

definition

A named container in a program that stores a value, which can be read, updated, or replaced. Programs work with data by storing and updating it in variables—without them nothing persists.

💡 Intuition

A labeled box you can put things in, take things out, or change what's inside.

Core Idea

Variables give meaningful names to data values so programs can store, retrieve, and modify them.

🔬 Example

score = 0, then score = score + 10 updates the box, so score now holds the value 10.

🎯 Why It Matters

Programs work with data by storing and updating it in variables—without them nothing persists.

⚠️ Common Confusion

= means 'assign' not 'equals'. x = x + 1 is valid (not a paradox).

Related Concepts

How Variable Connects to Other Ideas

Once you have a solid grasp of variable, you can move on to data types and assignment.

Learn More

Go Deeper

Frequently Asked Questions

What is Variable in CS Thinking?

A named container in a program that stores a value, which can be read, updated, or replaced.

Why is Variable important?

Programs work with data by storing and updating it in variables—without them nothing persists.

What do students usually get wrong about Variable?

= means 'assign' not 'equals'. x = x + 1 is valid (not a paradox).

💻 Animated Visualization Animated

See how a variable's value changes over time