Topic 0 · Programming Fundamentals (Python)
Computer Science · Cheatsheet

Topic 0 · Programming Fundamentals (Python)

Chapter 1 · Sequence, selection & iteration

📋 Reference · always available
Variable
A named box in memory. `x = 25` stores 25; a later `x = 78` replaces it.
= vs ==
`=` stores a value; `==` tests equality.
// and %
`//` floor-divides; `% 10` gives the last digit, `// 10` drops it.
while loop
Repeat *while* a condition is true: init → test → update, or it never stops.
for / range
`for i in range(a, b):` runs i = a … b−1 → b−a times.
if / elif / else
Runs the FIRST true branch only; put narrow conditions first.
Tracing
Track every variable line-by-line — the #1 exam skill.
IB pseudocode
`loop while … end loop`, `if … then … end if`, `output` — exam answers use this, not Python.