The Python course
Four tiers of Python, from your first printed line to generators, async and testing. Every lesson runs in your browser and every exercise is checked.
Every exercise is checked as you go. Create an account to keep your progress, or try it first without one.
Foundations
From a blank file to small working programs.
Values and variables
Write your first working programs: show a value, store one under a name, and move between text and numbers.
Conditions and branching
Make a program choose, with if, elif and match, and combine conditions without tying them in knots.
Loops
Repeat work with while and for, and walk a sequence while keeping totals, positions and flags straight.
Lists
Build, slice, sort and filter lists, and handle grids made of them.
Dictionaries, sets, tuples
Store data under names rather than positions, count and group it, and pick the collection that fits the question.
Functions
Turn a long script into named functions that take arguments and hand answers back.
Working Python
The things you need before writing anything real.
Errors and exceptions
Read a traceback, catch the failure you expected, and raise one a caller can act on.
Files and the filesystem
Read and write files, and handle paths, folders, CSV and JSON without string surgery.
Classes and objects
Keep data and the code that looks after it in one place, in classes that cannot be put into a broken state.
Modules and imports
Split a program across files and packages, and know what import actually does.
Comprehensions
Write the list-building loop you already know as one expression, and recognise when not to.
Type hints
Say what your functions take and hand back, and read what a type checker tells you.
Standard library tour
Learn the parts of the standard library worth knowing by name, and reach for them before writing your own.
Advanced
The features that separate working code from good code.
Iterators and generators
Write generators that hand out values one at a time, and chain them into pipelines over data too big to hold.
Decorators
Read the @ line for what it is, and write decorators that wrap, configure and register functions.
Context managers
Put anything inside a with block that is guaranteed to be tidied up afterwards.
Dataclasses and the data model
Let a dataclass write the boilerplate, and learn the methods Python calls on your behalf.
functools and itertools
Replace hand-written loops with the tools that already do the job, and judge when they read better than a loop.
Applied
Structure, tests, and code meant to be maintained.
Async syntax and event loops
Write coroutines that wait without blocking, and run many of them at once.
Testing
Write tests that fail when the code is wrong, and make hard-to-test code testable.
Patterns and architecture
Give a growing program a shape: a pure core, a thin shell, and pieces you can swap.