The Python handbook
Write your first line of Python, then build a program you can test and share. Each lesson pairs a worked example with a question that helps you explain the result.
total = 0
for price in [4, 7, 2]:
total += price
print(total)
| Step | price | total |
|---|---|---|
| 01 | 4 | 4 |
| 02 | 7 | 11 |
| 03 | 2 | 13 |
Curriculum
01Getting startedInstall Python and run your first script from a terminal.6 lessons
02FoundationsCalculate a total, name the result, and format it for a reader.11 lessons
03Control flowChoose a branch and trace a loop from its first pass to its last.6 lessons
04Data structuresChoose a collection that preserves the information your program needs.10 lessons
05FunctionsMove repeated work into functions with explicit inputs and results.6 lessons
06Object-oriented PythonGive related data and behavior a home in a class.3 lessons
07Reliable codeFind the cause of a failure and write a test that catches it.5 lessons
08Files and projectsOrganize modules and read structured records from disk.10 lessons
09Intermediate PythonBuild iterators and context managers, then explain when they run.9 lessons
10Developer workflowTest a project, work with a database, and measure performance.10 lessons
11Guided projectsBuild working tools, from a calculator to a persistent task manager.5 lessons
12Professional practicePackage an application and verify a release against existing data.5 lessons
13Advanced language and runtimeReason about object identity, concurrency, typing, and representation.10 lessons
- Inheritance and method resolution
- Descriptors and attribute lookup
- Structural typing with protocols
- Task groups and cancellation
- Generics and relationships between types
- Threads, shared state, and locks
- Object lifetime and weak references
- Equality, hashing, and dictionary keys
- Unicode text and normalization
- Decimal arithmetic and rounding policy