Try the Python courses
7 Python courses and 113 exercises, open to try free in your browser — no sign-up, nothing to install and nothing saved. Each exercise has a problem, starter code, hints and tests that check your code instantly, and links to the lesson that teaches what it needs.
Python Fundamentals
A first Python course, supported by 19 core concept lessons. Start with output, input and variables, then use decisions, loops and functions in progressively broader programs.
- Hello, World!
- Welcome Aboard
- Hello, Human
- Name and Age
- Age in the Future
- Who Goes There?
- Grade Calculator
- Name Shout
- Repeated Greetings
- Check the Age
- Seven Guesses
- Guess with a Score
- Times Table
- Merry Christmas
- Christmas Tree
- Function Basics
- Adding and Subtracting
- The Login Gate
- Introduction to Lists in Python
- Multiples Machine
- Bug Clinic
- Closest Guess
- Factor Finder
- Prime Detector
- Pair Every Name with Every Game
- The Prime Collector
- All Passed
- Score a Memory Game
- Introduction to Dictionaries in Python
- Account Lookup
- Find and Replace
- Program Menu
- Weather Readings
- Process Login Attempts
- Dice Battle
- Palindrome Discovery
- Card Game Champion
Python Skills for Lineup 4
Build the Python skills for a Lineup 4 agent: read positions and board dictionaries, find legal moves, check whether the centre is free, use lists to express preferences, build every winning line, then search those lines for a move that wins immediately.
- The Position Code
- Reading the Board
- Where Does the Piece Land?
- Every Legal Move
- Is the Centre Free?
- Play as central as I can
- Find all winning sets?
- Find a Winning Move
Python Basics with Turtle
Learn the first ideas of Python by drawing with a turtle: printing, variables, arithmetic, input, for loops, decisions and functions. Every program draws something, and the tests check the drawing. Press Run to watch the turtle draw; drawing needs Python running in your browser.
- Hello, Turtle
- Turtle Says Hello
- Rectangle Variables
- Rectangle Perimeter
- Triangle on Request
- Loop Any Polygon
- Square Spiral
- Square or Triangle?
- Polygon by Name
- A Polygon Function
- Polygon Perimeter
- Shape Picker
API basics
Talk to real web APIs with Python's requests library. Learn to fetch a response, inspect its values and structure, find the fields you need, and turn them into a useful report. Practise query parameters and pagination, failed requests, missing data, request and response headers, POSTing JSON, and bounded retries after 429 Too Many Requests. By the midpoint, use a supplied inspector to explore a large response as keys and Python types. Finish with an unfamiliar Pokémon species response and a report that handles failed requests. No accounts or API keys are needed.
- Your First GET Request
- Query Parameters
- Follow the Next Page
- Status Codes
- When Requests Fail
- Book Report
- Map a Response
- Reading Response Headers
- Sending Headers
- POST Some JSON
- Capital Quiz
- Pokemon Leaderboard
- Too Many Requests
- Retry Politely
- Species Field Report
Python Object-Oriented Programming (OOP) with Dataclasses
Object-Oriented Programming in Python, taught through short coding exercises. Build Python classes and independent objects, put behaviour in methods, and use a Python dataclass to remove repetitive setup code. Practise OOP concepts with examples of field defaults, equality, separate mutable lists, composition, validation, frozen values, inheritance and polymorphism. Finish by validating and exporting a small gradebook.
- Python Classes: Create Independent Objects
- Python Objects: Update a Parcel Collection
- Python Methods and self: Change Object State
- OOP Example: Fill a Tank Without Overflow
- Your First Python Dataclass
- Dataclass Methods: Calculate Route Times
- Python Dataclass Defaults and Equality
- Dataclass Challenge: Find the Basketball Leaders
- Python Dataclass default_factory: Separate Lists
- Dataclass List Methods: Avoid Duplicate Members
- OOP Composition: Add Up Objects in a Dataclass List
- OOP Composition Example: A Building of Floors and Rooms
- Dataclass Validation with __post_init__
- Dataclass Validation Example: Reservation Limits
- Frozen Dataclasses: Make an Updated Copy
- Frozen Dataclass Example: Award Score Bonuses
- Python OOP Inheritance and Method Overriding
- OOP Polymorphism Example: Total Mixed Tickets
- Python Dataclass asdict: Export Nested Records
- OOP Dataclass Project: Build a Batch Grader
Python Context Managers: the with Statement and @contextmanager
Learn Python context managers: what the with statement does, and how to write your own context manager with @contextmanager from contextlib. Start with a context manager that runs code before and after a with block, then use try/finally so the clean-up runs even when the block raises an error. Change a game setting and restore it, yield an open file to with ... as, and put multiple context managers in one with statement to work with several files at once. Finish by writing the same context managers as classes with __enter__ and __exit__.
- Write Your First Context Manager with @contextmanager
- Nested with Statements: Two Context Managers
- try/finally: Cleanup That Runs Even After an Error
- Temporary Settings: Change a Value and Restore It
- with ... as: Yield a File from a Context Manager
- Multiple Context Managers in One with Statement
- Merge Score Files into a Leaderboard
- __enter__ and __exit__: a Context Manager Class
- Context Manager Class with __init__ and a Return Value
- Temporary Settings as a Context Manager Class
Python Generators
Learn generators: generator expressions, yield, infinite generators and close(), then for loops, lazy evaluation, filters, pipelines, reading a file line by line and memory, ending with a lazy log-file parser. Assumes basic functions, arithmetic, lists, loops and reading text files.
- Your First Generator: next()
- Write a Generator with yield
- Infinite Running Totals
- Infinite Fibonacci and close()
- Loop Over a Generator with for
- yield vs return: Lazy Evaluation
- Filter Lines with a Generator
- Generator Pipeline: Take the First N
- Read a File Line by Line
- Generator Expression vs List: Memory
- Parse a Log File with Generators
Want to keep your progress? Sign up free to save every exercise you pass and get AI hints. Reading first? Browse the Python lessons. Teaching a class? See Agent Games for teachers.