PythonMastery

Learn Python the way you will use it.

Short, focused lessons that take you from your first print() to writing real scripts: reading data, automating everyday tasks, and building small tools you will use again. Runs in your browser. Works on a phone. Free forever.

Not sure which path? The roadmap puts them in order, from zero to employable.

222lessons
53h 17mtotal time
17paths
3.13Python version

Printable cheat sheets

24 topics, one A4 page each, from strings and loops to NumPy and pandas. Every example on them is run with Python before the sheet is printed, and each sheet ends with the mistakes people often make.

See all 24 cheat sheets

Choose your path

222 lessons · 53h 17m total

Core Python

4 paths

Take these in order, from your first print() to large projects.

Start here

Python Fundamentals

Start here if you've never written code. Variables, control flow, functions, lists and dictionaries: the basics you need before anything else makes sense.

level
beginner
requires
no prior coding
length
19 lessons · 4h 33m
format
read → run → quiz
You’ll build: small Python scripts that handle user input cleanly and produce useful output.
0 / 19 lessons Start →

Python Intermediate

After the basics, this is where Python becomes useful for real work: OOP, files, exceptions, comprehensions, decorators and the other techniques you will use every day.

level
intermediate
requires
Fundamentals or equivalent
length
13 lessons · 3h 52m
format
read → run → quiz
You’ll build: a command-line task manager that uses classes, files, and proper error handling.
0 / 13 lessons Begin →

Python Advanced

Metaclasses, descriptors, async, type hints and performance: the topics you need to understand how large Python projects and libraries work.

level
advanced
requires
Intermediate
length
9 lessons · 3h
format
deep dives
You’ll build: a small library with type hints, async I/O, and proper packaging.
0 / 9 lessons Begin →
build & ship

Projects

Use what you have learned to build complete, working Python programs. Each project goes through the build step by step, then gives you extra goals to try on your own.

level
beginner
requires
Comfortable with Fundamentals
length
15 lessons · 6h 30m
format
guided build
You’ll build: complete Python programs you can show your friends: a tip calculator, a guessing game, a to-do list, a password generator and more.
0 / 15 lessons Begin →

Choose a direction

After the basics, pick the area you want to work in.

Data science & AI

6 paths

From your first DataFrame to models and LLMs. Beginner on the first row, then deeper.

Data Science Fundamentals

An easy start in data science: what it is, why it matters, and your first hands-on pandas analysis. Each idea is explained in plain words before any technical terms.

level
beginner
requires
Fundamentals
length
6 lessons · 1h 46m
format
guided
You’ll build: your first exploratory data analysis on a real CSV.
0 / 6 lessons Begin →

Machine Learning Fundamentals

Machine learning without heavy maths. Linear regression, classification, decision trees, and the metrics that tell you if a model is good.

level
beginner
requires
Fundamentals
length
6 lessons · 1h 25m
format
guided
You’ll build: a churn classifier you can explain to a non-engineer.
0 / 6 lessons Begin →

Deep Learning Fundamentals

Neural networks explained in plain words first, then built with Keras. CNNs for images, RNNs for sequences, and what each line of training code does.

level
beginner
requires
ML Fundamentals
length
7 lessons · 2h 42m
format
guided
You’ll build: an image classifier with the training loop you wrote yourself.
0 / 7 lessons Begin →

Data Science & ML

NumPy, Pandas, Matplotlib, and just enough statistics to not embarrass yourself. Real datasets, real questions, no toy examples.

level
intermediate
requires
Fundamentals
length
9 lessons · 3h 15m
format
applied
You’ll build: a complete analysis of a real dataset: load it, clean it, plot it and explain what you found.
0 / 9 lessons Begin →

Generative AI & LLMs

How ChatGPT, Claude and other large language models work (tokens, attention, embeddings, RAG, fine-tuning), and how to use them from Python.

level
intermediate
requires
Deep Learning Fundamentals
length
6 lessons · 2h 12m
format
applied
You’ll build: a retrieval-augmented assistant over documents you supply.
0 / 6 lessons Begin →

AI & Deep Learning

Neural networks, CNNs, NLP, GANs, and how the parts of a production AI system fit together. Theory only where it helps, and working code everywhere else.

level
advanced
requires
Data Science
length
9 lessons · 4h 11m
format
applied + project
You’ll build: an image classifier and an NLP pipeline, written the way they would be in a real project.
0 / 9 lessons Begin →

Web & backend

4 paths

Build web apps and APIs, secure them, store their data and put them online.

ship the app

Web Frameworks

Flask, FastAPI and Django: when to use each one, how to build a working app in each, and the patterns real teams use. Authentication and databases have their own tracks.

level
intermediate
requires
Fundamentals + a touch of Intermediate
length
12 lessons · 4h 38m
format
guided build
You’ll build: working APIs and apps in all three frameworks. Learn one, or learn to choose the right one for each project.
0 / 12 lessons Begin →
lock the doors

Auth & Security

Password hashing, sessions, JWT, OAuth2 with real providers, and the OWASP-flavoured security checklist every web app needs before it goes live.

level
intermediate
requires
Web Frameworks (or general HTTP literacy)
length
4 lessons · 1h 31m
format
guided build
You’ll build: a hardened login system you can drop into any Flask or FastAPI app.
0 / 4 lessons Begin →
ship & operate

DevOps & Deploy

Docker, GitHub Actions, environments and secrets: the work that takes code from 'works on my laptop' to 'works in production'.

level
intermediate
requires
Intermediate Python + comfort with the command line
length
4 lessons · 1h 34m
format
guided
You’ll build: a Python project containerised, tested in CI, and deployed with secrets handled properly.
0 / 4 lessons Begin →
production data

Databases (Production)

The next step after SQLite: Postgres with psycopg/asyncpg, Redis for caching and queues, MongoDB for document data, and ORM patterns that stay fast in production.

level
advanced
requires
Intermediate (fileio, exceptions) and How-to databases
length
4 lessons · 1h 49m
format
guided
You’ll build: the data-layer skills to move a side project from SQLite to a real production database.
0 / 4 lessons Begin →

Use any time

Open these whenever you need them: a task to solve, an error, a syntax reminder, a ready program, a habit to learn.

pick a task

Python How-To

Step-by-step answers to the tasks people search for most: the terminal, Git, scraping, APIs, CSVs, databases, automation, testing, logging and packaging.

level
beginner
requires
any level: pick what you need
length
14 lessons · 4h 44m
format
practical reference
You’ll build: small tools you will use again, plus the terminal and Git skills every job expects. The examples use as few extra packages as possible.
0 / 14 lessons Begin →
when it breaks

Errors

The Python errors you are most likely to meet, from a wrong indent to a server that stops at 2am. For each one: what the message means, the code that causes it, and the fix. You can run every example here.

level
reference
requires
any level: bring your error message
length
60 lessons · 3h 14m
format
look it up → fix it
You’ll build: the habit of reading a traceback and knowing, in one look, which line is lying to you.
0 / 60 lessons Look it up →
look it up

Reference

Cheat sheets and a glossary for when you forget the syntax: comprehensions, slicing, f-strings, datetime, regex. Short pages with just the answer.

level
reference
requires
any level: when you need a fast answer
length
25 lessons · 2h 21m
format
reference
You’ll build: a single source of truth for the Python syntax and terms you'll Google a hundred times.
0 / 25 lessons Begin →
write it better

Tips & tricks

Short, practical habits that experienced Python developers rely on: the before, the after, why it works, and when not to use it. Plus how real projects like Dropbox and Spotify used these ideas at scale.

level
any
requires
any level: start anywhere
length
31 tips · 5 case studies
format
before → after, runnable
You’ll pick up: the small habits that separate code that works from code you’re happy to hand over.
31 tips Browse →
quick lookup

Short answers

One page per question people type into a search box: read a CSV, parse JSON, use SQLite, sort a dictionary by value, call an API. The code first, then the one or two things that trip people up.

level
any
requires
nothing: look up what you need
length
26 questions
format
answer first, runnable
You’ll pick up: the working line of code, and why the obvious version sometimes isn’t it.
26 answers Browse →
see it work

Python programs

Classic programs in order, from Hello World and leap years to sorting, file handling and small tools. Each page has the code, the real output, a Run button and a short explanation of how it works.

level
beginner first, then harder
requires
nothing: start at program 1
length
195 programs · 141 for beginners
format
code, output, how it works
You’ll pick up: how the ideas from the lessons fit together into complete, working programs.
195 programs Browse →
learn from others

Lessons from incidents

Real outages, lost data and a malicious package (Cloudflare, GitLab, PyPI): what went wrong, told from each company’s own write-up, and the habit that would have caught it. Every story ends in code you can run.

level
intermediate
requires
basic Python
length
3 incidents
format
story → cause → runnable fix
You’ll pick up: the checks that stop a small mistake becoming a public post-mortem.
3 incidents Read →

Tools that come with it

for the data science, ML and AI tracks

The data tracks expect you to run the code yourself, and you can. scikit-learn, XGBoost, LightGBM, pandas and statsmodels all run in this tab, with no install, and your code never leaves your device. Train a model, score it on a test split, plot the result. PyTorch and TensorFlow are the honest exceptions: no WebAssembly build exists, so those lessons ask you to run locally and say so plainly.

Charts render as high-resolution images, and Plotly figures render live: you can drag to rotate a 3D scatter plot or a loss surface and look at it from every side.

Before you start.

A short, honest note. It takes two minutes to read.

What you'll get

  • A working understanding of Python in roughly twelve hours of focused time.
  • Real, useful scripts before the end of the second path.
  • Lessons that run on any device you have: a phone, a school laptop, anything.
  • Free, forever. Your code stays in the browser.

What we won't pretend

  • This won't make you a senior engineer. Real depth comes from building your own things.
  • It won't replace a CS degree if a job filter demands one.
  • We don't cover every library, only the ones you are most likely to need.
  • The hard parts are still hard. We explain them clearly, but we don't pretend they are easy.

Recently shipped

and what should come next is up to you

222 lessons (including 60 error write-ups), 195 Python programs, 31 tips, 26 short answers and 24 cheat sheets so far, and the site is still being written. These four arrived most recently. We also ran every code example in the lessons again, fixed the ones whose output did not match the page, and rewrote the text in plainer English. There’s no newsletter and no notify me box. If there’s something you want next, say so with the feedback button. Requests are how we pick what to build.

✓ Shipped

input() works in every browser

Programs that ask a question with input() or pause with time.sleep() now work in Safari, Firefox and every browser on iPhone and iPad, in the editor and in the lessons, and Stop works there too. The editor also completes names from your own code, for example math.sqrt after import math.

Try it in the editor →
✓ Shipped

Choose your Python version

The editor now runs Python 3.14, 3.13, 3.12 or 3.11: click the status line above the output to switch, and share links keep the version. The lessons, examples and notebook stay on 3.13, the version every output on them was checked on.

See what changed →
✓ Shipped

Python programs for beginners

195 classic programs, from adding two numbers to sorting, games and small tools. Each page has the code, the output and a short explanation, and you can run it in your browser.

Browse the programs →
✓ Shipped

An error finder

Paste a traceback and it finds the page that fixes it (60 errors written up), or explains the error and points at the line of your code to look at. Failed runs in the editor and the lessons now have an Explain this error link.

Paste an error →

Everything already here stays free, and everything new will be free too: no account, no paywall, no email sign-up.

pricingFree, forever.

No paywall, no premium tier, no email gate. Your code runs in your browser, not on servers we rent, which is what makes free possible. There are no ads today. When they arrive they'll be clearly labelled, and the lessons stay free either way.