learn
The path
Each track is a couple of short lessons — predict, read, run, change — and after each, exercises you write yourself. Take them in order if you are new; skip freely if you are not.
1 · The basics
First programs
Print something. Read something. Run it and see.
Names and values
A name holds a value; arithmetic makes new ones.
Decisions
if, elif, else — and exactly one branch runs.
Loops
Do it again: for over a range, while until something is true.
Functions
Name a piece of work, give it inputs, get a value back.
Lists
Many values under one name, and the difference between a new list and a changed one.
Strings
Text is a sequence too: index it, loop over it, build new ones.
Dictionaries
Look things up by name instead of by position.
2 · Data structures and algorithms
Counting steps
Two right answers can differ by a factor of a thousand. Measure it.
Searching
Look at everything, or halve the problem each time.
Sorting
Put things in order yourself, once, to know what sorted() is doing.
Stacks and queues
Last in, first out; first in, first out.
Hash maps and sets
Trade memory for time: remember what you have seen.
Recursion
A function that calls itself on a smaller problem, and a base case that stops it.
Linked lists
Nodes that point at the next node. Relink them without losing any.
Trees
Nodes with two children, and the recursion that walks them.
Graphs
Neighbours, visited sets, and breadth-first search.
Dynamic programming
Solve each small problem once and keep the answer.