📦 Variables: the computer's memory
Why: Store and reuse values with variables — the computer's memory.
Unlocks: Math on your data, and every program that remembers anything.
Remember the switch machine? Eight light switches storing a number. A variable is the friendly face of that same idea: a labeled box in the computer's memory where you store a value to use later.
age = 30 means: “take a box, write age on the label, put 30 inside.” From then on, whenever you say age, Python opens the box.
Boxes can be refilled. When you assign again, the old value is thrown away — the box keeps only the newest thing:
And boxes can be built from other boxes. This is where programs start feeling alive:
After running: x = 5 then x = 9 — what's in the box x?
What's the difference between print(mood) and print("mood")?
🔍 Go deeper: watch boxes get created and refilled step by step → PyDebug: Variables & Data Types.