What is a Variable?
In Python, a variable is a named location in memory that stores a piece of data. Think of it as a labelled box โ you give the box a name, put something inside, and can retrieve or update that value at any point in your program.
Real-world analogy
score = 0 at the top. As the quiz progresses, she erases 0 and writes the latest total. The label "score" stays fixed โ only the value inside changes. That is exactly what a Python variable does.Name
Every variable has a unique identifier (e.g. score, player_name, is_alive) that you choose when you create it.
Value
The data stored inside โ a number, text, True/False, or a more complex object.
Mutable
Unlike a fixed constant, a variable's value can be updated as many times as needed while the program runs.
No declaration needed
Python is dynamically typed. You don't need to say 'this is an integer' โ Python figures it out automatically.
Key vocabulary
- Assignment โ storing a value in a variable using the = operator.
- Data type โ the kind of data stored (int, float, str, bool).
- Dynamic typing โ Python infers the type automatically.
- Re-assignment โ giving a variable a new value (can even change its type!).