Variables are name tags that point to objects in memory, each object has a type that determines what operations are valid, and expressions combine values and operators to produce new results.
The Name Tag Model (Threshold Concept)
WRONG mental model RIGHT mental model
┌──────────┐ ┌───┐ ┌──────┐
│ x │ 42 │ │ x │────▶│ 42 │
└──────────┘ └───┘ └──────┘
(box holding a value) (name tag pointing to an object)
Assignment (x = 42) makes a name tag point to an object
Reassignment (x = 99) moves the name tag — it doesn't change the old object
Multiple names (b = a) makes two name tags point to the same object
Verify with id(): if id(a) == id(b), they point to the same object
The Four Fundamental Types
Type
Python Name
Example Values
Falsy Value
Common Conversions
Integer
int
42, -7, 0
0
int("42"), int(3.7) → 3 (truncates!)
Float
float
3.14, -0.5, 1.0
0.0
float("3.14"), float(42) → 42.0
String
str
"hello", "", 'a'
""
str(42) → "42", str(True) → "True"
Boolean
bool
True, False
False
bool(0) → False, bool("") → False
Arithmetic Operators
Operator
Name
Example
Result
Type of Result
+
Addition
7 + 3
10
int
-
Subtraction
7 - 3
4
int
*
Multiplication
7 * 3
21
int
/
True division
7 / 3
2.333...
always float
//
Floor division
7 // 3
2
int
%
Modulo
7 % 3
1
int
**
Exponentiation
2 ** 10
1024
int
Precedence:** → unary - → * / // % → + - (use parentheses when in doubt)
Meaningful names: midterm_score beats m, temperature_celsius beats t
Never use: l (lowercase L), O (uppercase O), I (uppercase I) — they look like digits
What's Next
Chapter 4: Making Decisions — Conditionals and Boolean Logic. The boolean expressions from this chapter become the building blocks for if, elif, and else statements.