2 · Variables & primitive types
Names that hold values, and the four primitive types every Python program uses.
One idea, one try. At your own pace.
LEARN BY DOINGPut your intuition to work3 steps
2 · Variables & primitive types
Use the lesson’s examples and explanation to check your idea.
Personal reflection. Nothing is sent to an AI service.A variable is a label pointing at a value — assign with `=`, never `==`.
Without this:
Without variables, you cannot reuse a value, name an intermediate result, or build anything beyond a one-shot script.
Python is dynamically typed: a variable's type is the type of whatever value it currently holds. Bind a value to a name with =.
Python (in browser)
Four variables, four different primitive types. Run it and check the type() output.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
f-strings are the modern way to interpolate values into text. They start with f and embed expressions in {}.
Python (in browser)
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Shebang line + module docstring + a top-level CONSTANT in UPPER_SNAKE_CASE. The conventions you'll see in real codebases.
If 'function' and 'value' feel hand-wavy, read the MML opener — it grounds the mental model.
- Variables are bindings (name → value), not boxes. Reassignment changes what the name points at.
- The four primitives — `int`, `float`, `str`, `bool` — cover most simple values you'll see.
Hyperparameters are variables (`learning_rate = 0.01`); model state is held in variables (`model = LinearRegression()`).
If you remove it: Without named state, every experiment becomes a wall of literal numbers — unreadable and untunable.