Overview
Your complete guide to Python foundations
Eight lessons from your first line of Python: decisions and loops, functions, lists and dictionaries, errors, files and JSON, and how to read an error message. Each lesson opens with an animation and code you run yourself.
Each part opens with an animation, then what you need before you start, then the idea with code you run, then a step-by-step and a worked example. Read the parts in order, as each builds on the last.
Each part ends with myth vs reality, a multiple-choice question, cards that flip when tapped, and "check your understanding" questions with hidden answers. Use them before you say "got it".
Do not leave a part before its exercise tests pass. Reading alone proves nothing; the exercise does.
Pick a topic
A look at Python foundations
The lessons are ordered so each builds on the last: you run a first file, make it decide and repeat, gather code into functions, keep data in lists and dictionaries, handle errors, read and write files and JSON, and finally learn to find a bug yourself.
| Part | Topic | You learn |
|---|---|---|
| 1 | Environment & First Programs | The prompt and the file, pip and virtual environments |
| 2 | Control Flow | if, elif and else, for, while and range |
| 3 | Functions & Modularity | def and return, default values and imports |
| 4 | Core Data Structures | Lists, tuples, sets and dictionaries |
| 5 | Exception Handling | try, except, else and finally, and raising errors |
| 6 | File Handling | Open modes, with, reading line by line, encoding |
| 7 | Serialization | JSON, Pickle, CSV and XML |
| 8 | Debugging Strategies | Reading a traceback, print, pdb and logging |