Overview
Variables are named storage boxes; types tell Python what kind of data lives inside.
Analogy
Labeled jars: an 'age' jar holds a number, a 'name' jar holds text.
Step-by-step
- Assign with =: x = 5.
- Python infers the type automatically.
- Use type(x) to inspect the type.
Visual
x = 42 → box labeled x contains int 42
Common mistakes
- Using a variable before assigning it.
- Expecting + to concatenate an int and a string without conversion.
Practice questions
- Create variables for name, age, and height; print their types.
- Reassign a variable from int to string and observe.