The course
One path, in order. Each lesson is a small program you step through, watching the state change line by line — and most ship with the buggy version a beginner writes, watched failing. Start at the top, or jump to whatever you came for.
1Foundations: values & types
Before any algorithm: what a value is, the types a beginner meets, and how a name binds to a value.
- 1Values and namesA name points at one value — rebind it and the old value is gone, unless you saved it first.
- 2Numbers have types: int vs floatTwo ways to divide: // drops the remainder and gives an int, / keeps it and gives a float.
- 3Converting a float to an intint() truncates 3.9 to 3; round() gives 4 — watch which one you reach for.
2Arithmetic & division
How numbers combine: precedence, the power operator, and modulo — the remainder that wraps around.
3Comparisons & booleans
How a program asks a yes/no question: comparisons produce a bool, operators combine them, and most values are truthy or falsy.
- 7A comparison is a yes/no valueStore the result of age > 18 — a real bool — and watch > miss the boundary that >= keeps.
- 8Truthiness: what counts as trueA non-empty list is truthy but never equals True — watch == True skip the branch you wanted.
- 9and / or / notWatch x == 1 or 2 quietly become 2 (always truthy) — and the fix that compares both values.
4Decisions: the if / elif ladder
Putting conditions to work as control flow — where the order of branches is the whole game.
- 10Choosing one branch with if / elseWatch two separate ifs both run, the second clobbering the first — and elif pick just one.
- 11The elif ladder: order mattersWatch a 95 graded D because the loosest band was tested first — first true branch wins.
- 12FizzBuzzmilestoneMilestone: loops + if/elif + modulo — and the unreachable branch that grades 15 wrong.
5Programs & state
Tiny imperative programs, traced line by line — including the bugs that destroy or mis-store state.
- 13Swapping two valuesThree ways to swap two cups — including the one a beginner writes, watched failing.
- 14Adding up a listKeep a running total — and watch the = vs += bug stop it from ever adding.
- 15Running maximummilestoneMilestone: the accumulator + comparison — and a zero seed that breaks on all-negative data.
- 16Linear searchFind where a value lives — and watch the index-vs-value mix-up return the wrong thing.
- 17Filtering a listKeep the items that pass a test — and watch deleting-while-looping skip an element.
- 18Palindrome checkmilestoneMilestone: strings + indexing + comparison — and pairing the wrong letters.
- 19Collecting rainwatermilestoneMilestone: arrays, loops and min/max combine to trap water between columns — with a cool visual.
6Mutability & aliasing
Some values can be changed in place, and two names can point at one object — so changing 'one' changes 'both'.
7Functions
Packaging an idea you can call: a function opens its own scope, takes parameters, and must hand a value back.
8Data & representation
How computers store information — every bit of it a program you can trace.
- 24Decimal to binaryWatch 13 fill the powers-of-two columns to become 1101 — place value, traced as real Python.
- 25Binary to decimalTurn 1101 back into 13 by doubling — and watch the base mix-up read it as eleven hundred.
- 26Run-length encodingCompress a row of pixels into (length, colour) pairs — and watch the bug that drops the last run.
- 27OverflowWatch an 8-bit counter wrap 255 → 0 — and watch Python's unbounded ints refuse to.
- 28RoundoffWatch 0.1 + 0.2 come out as 0.30000000000000004 — and why == is a trap on floats.
9Systems & networks
How machines talk — modelled as small simulations and traced like any other program.
- 29Packet switchingsimulationFollow a packet hopping across a network graph from A to D, one hop at a time.
- 30Fault tolerancesimulationFail a node and watch a redundant network reroute — while a single-path one strands the packet.
- 31Packets take different routessimulationOne message, three packets, three routes — arriving out of order and reassembled by sequence number.
- 32Parallel speedupsimulationWatch two workers halve the time on independent tasks — and a dependency chain refuse to speed up at all.