Learn Python, for free.

Short lessons you can run right here in your browser. Write real code in the first two minutes, get instant feedback, and build up one small step at a time. No sign-up and nothing to install.

Start with lesson 1I already code in another languageAlready know some Python? Take the placement test

How each lesson works

  1. Read a short explanation with an example.
  2. Try it: edit and run code in the built-in editor.
  3. Check your answer. Clear hints help when you are stuck.

Not sure where to start? The placement test takes about five minutes and suggests the right lesson. If you already program in another language, the fast track skips the basics and shows what is different in Python.

The course

72 lessons in 11 modules, about 21 hours in total. Plus 16 lessons in optional tracks, below.

Module 0 Start Here

A five-minute tour of the tools you will use in every lesson.

  1. How This Works5 min

Module 1 Foundations

Write and run your first programs: printing, values, variables and doing math with them.

  1. Hello, World!10 min
  2. Variables12 min
  3. Reading Error Messages12 min
  4. Values and Types12 min
  5. Asking for Input and Converting Types15 min
  6. Arithmetic and Operators15 min
  7. Working with Text (Strings)15 min
  8. f-strings: Building Text from Values12 min
  9. Booleans and Comparisons15 min

Module 3 Data Structures

Hold many values at once: lists, slices, sorting, tuples, dictionaries, sets and comprehensions.

  1. Lists: Keeping Many Values Together15 min
  2. Looping Over Lists15 min
  3. Slicing: Taking Part of a List12 min
  4. Sorting Lists15 min
  5. Tuples and Unpacking15 min
  6. Dictionaries: Looking Things Up by Name18 min
  7. Sets, and Choosing the Right Structure15 min
  8. Comprehensions: Building Collections in One Line15 min

Module 4 Functions

Package code into reusable, named pieces: parameters, return values, scope, recursion and a quiz-engine project.

  1. Defining and Calling Functions15 min
  2. Return Values15 min
  3. Default, Keyword and Variable Arguments18 min
  4. Scope: Where Variables Live15 min
  5. Functions as Values, and Lambdas15 min
  6. Recursion: Functions That Call Themselves18 min
  7. Docstrings and Type Hints15 min
  8. Project: A Quiz Engine35 min

Module 5 Text and Files

Work with text like a pro, then read and write files, CSV and JSON, and find patterns with regular expressions.

  1. String Methods in Practice15 min
  2. Reading and Writing Text Files18 min
  3. Paths and Folders with pathlib15 min
  4. CSV Files: Tables as Text18 min
  5. JSON: Saving Structured Data15 min
  6. Regular Expressions: Finding Patterns20 min

Module 6 Errors and Debugging

Handle failures gracefully with try/except, raise your own errors, hunt bugs methodically, log what happens, and finish with an expense-tracker project.

  1. Catching Errors with try and except15 min
  2. Raising Your Own Exceptions18 min
  3. Debugging Strategies20 min
  4. Logging Instead of print18 min
  5. Context Managers and with18 min
  6. Project: An Expense Tracker40 min

Module 7 Modules and Tooling

Use Python's standard library with confidence, install packages safely, and organise a project so it can grow.

  1. Importing Modules15 min
  2. The collections Module18 min
  3. Dates and Times18 min
  4. itertools and random18 min
  5. Packages, pip and Virtual Environmentsown computer20 min
  6. Organising a Python Project20 min

Module 8 Object-Oriented Programming

Bundle data and behaviour into classes, then use dunder methods, inheritance, composition, dataclasses, properties and abstract classes to design programs that grow.

  1. Classes and Objects18 min
  2. Methods: Giving Objects Behaviour18 min
  3. Dunder Methods: Making Objects Feel Built-in20 min
  4. Inheritance20 min
  5. Composition: Objects That Use Objects18 min
  6. Dataclasses18 min
  7. Properties: Controlled Attributes18 min
  8. Abstract Classes and Protocols20 min
  9. Project: A Small Bank45 min

Module 9 Pythonic Python

Write code the way experienced Python programmers do: iterators and generators, comprehension patterns, decorators, functools, type hints and a first look at async.

  1. Iterators and Iterables: How for Loops Really Work15 min
  2. Generators: Producing Values One at a Time18 min
  3. Comprehension Patterns and Generator Expressions16 min
  4. Decorators: Wrapping Functions20 min
  5. functools: Caching, Partial Functions and Reduce15 min
  6. Type Hints: Describing Your Data18 min
  7. async and await: Doing Waiting Work Togetherown computer20 min

Module 10 Testing and Quality

Prove that your code works with pytest, keep it readable and consistent, track it with Git, and package it so other people can install it. Ends with a capstone project.

  1. Testing with pytest: Writing Good Tests20 min
  2. Fixtures and Parametrize: Tests Without Repetitionown computer20 min
  3. Readable Code: Style, Formatters and Linters18 min
  4. Git Basics: Saving the History of Your Workown computer20 min
  5. Packaging: pyproject.toml and the src Layout20 min
  6. Project: Build, Test and Package a Mini Libraryown computer35 min

Optional tracks

Finished the basics (or at least Module 6)? These tracks apply Python to real jobs. They are never required. Lessons marked "own computer" need the local track: they must be run on your own computer, not in the browser.

Data Analysis

Use NumPy and pandas to load, clean, summarise and chart data: the everyday toolkit of data work. Runs in your browser (charts need your own computer).

  1. NumPy Arrays: Maths on Whole Lists at Once20 min
  2. pandas: Tables of Data with DataFrames22 min
  3. Selecting and Filtering Rows22 min
  4. Grouping and Summarising22 min
  5. Cleaning Messy Data24 min
  6. Project: Analyse a Sales Dataset35 min
  7. Charts with Matplotlibown computer22 min

Automation and Scripting

Write small tools that save you time: command-line programs, file and folder jobs, other programs, retries and schedules.

  1. Command-Line Programs with argparse22 min
  2. Working with Files and Folders in Bulk24 min
  3. Running Other Programs with subprocessown computer22 min
  4. Timing, Retrying and Scheduling24 min
  5. Project: A File Organiser35 min

Web and APIs

Understand how the web talks (HTTP), read data from JSON APIs, call web services, and build a small API of your own. Standard library only.

  1. How the Web Talks: URLs, Requests and Status Codes20 min
  2. Working with JSON APIs24 min
  3. Calling a Web Service with urllibown computer24 min
  4. Project: Build a Tiny JSON APIown computer40 min

Use it offline

Download Python once (about 15 MB) and the course works without a connection. You can also install it as an app from your browser's menu.

Your progress

Progress is saved only in this browser. Download a backup file to move to another device or keep it safe.