Python
From your first script to lists, dictionaries, classes and files, in Python 3.14.
Each lesson has runnable examples and exercises. Python is real (CPython 3.14), running in a small Linux machine inside this tab: no install, no server running your code. The first visit downloads about 12 MB, of which the first 4 MB before you can start; later visits start from your browser's copy.
Linux + Python 3.14 in your browser
22 lessons · 206 programs
Chapter 1 · Foundations
What runs your program; numbers, text, input and errors
- 1 Hello, Python
Your first program, the command that runs it, and print.
- 2 Inside the computer
What a computer is made of, what happens when your program runs, and where its values live in memory.
- 3 Names and numbers
Bind names to numbers, text and true/false, change them, and meet the two kinds of division.
- 4 Text and input
Join and format text with f-strings, and read what the user types.
- 5 Reading errors and tracebacks
Tell a syntax error from an exception, and read a traceback from its last line.
Chapter 2 · Decide, repeat, reuse
Decisions, loops, functions and modules
- 6 Decisions and loops
if, elif and else, for and while, the classic FizzBuzz, and a test of it all.
- 7 Functions
Name a piece of code, give it values, get one back, and see a frame per call.
- 8 Modules and programs
Use Python's built-ins and modules, write your own, and split a program into files.
Chapter 3 · Data
Text, lists, grids, dictionaries, sets and recursion
- 9 Working with text
Index, slice, split and join text, and format it into columns.
- 10 Lists
Keep many values in order, change them, and see when two names share one list.
- 11 Tuples, loops and grids
Pair values in tuples, loop with enumerate and zip, stop early, and walk a grid.
- 12 Dictionaries and sets
Look values up by key, count things, and keep unique values in a set.
- 13 Comprehensions and sorting
Build lists in one line, and sort anything by the key you choose.
- 14 Recursion
Solve a problem with a function that calls itself, and watch the frames pile up.
Chapter 4 · Objects and robust code
Classes, exceptions, generators, dataclasses and match
- 15 Classes and objects
Define your own kind of object with its data and its methods.
- 16 Inheritance and special methods
Build on a class, and teach your objects to print, compare and sort.
- 17 Exceptions
Catch what can go wrong, raise your own errors, and clean up.
- 18 Iterators and generators
See what a for loop really does, and make values only when they are asked for.
- 19 Dataclasses, enums and match
Shorter classes, named choices, and match to pick a case by its shape.
Chapter 5 · Real programs
Files, tested algorithms and a project of your own
- 20 Files
Read and write text, CSV and JSON files that outlive your program.
- 21 Practice: searching, sorting and testing
Search, sort and test by hand, then meet the tools real code uses.
- 22 A project of your own
Finish a small tool: a package that reads a CSV file, answers commands and prints a report.