Variables & Types: Mechanism
≈ 25 minMechanism
Follow the mechanism step by step and distinguish what causes the change from what is merely observed.
This extension applies that lens specifically to Variables & Types.
A variable is a name that refers to a value. You create one with =:
age = 15
Now age holds the integer 15. Python has a few core types:
| Type | Example | Meaning |
|---|---|---|
int | 7 | whole number |
float | 19.99 | decimal number |
str | "Thabo" | text (in quotes) |
bool | True | true / false |
You never declare the type — Python figures it out from the value. type(x) tells you a value's type.
Python Foundations — Mechanism: Assign the integer 7 to a variable called age.
Runs in your browser. Charts (matplotlib) are not supported — use print-based output.
Python Foundations — Mechanism: Create price holding the float 19.99 and name holding the string "Zanele".
Runs in your browser. Charts (matplotlib) are not supported — use print-based output.
Python Foundations — Mechanism: Which line correctly assigns the text Cape Town to a variable city?
Name the original topic being extended by this mechanism lesson.
Which statement is the best evidence-led starting point for Variables & Types: Mechanism?

