Learn Python by doing. Work through the lessons in order to go from running your first file to writing classes, handling files, testing, concurrency, type hints, and building a real web API. Awareness-only topics have been stripped out so every lesson has you writing code.
Before you start
Install Python (3.11 or newer) and VS Code. Create a folder, add a file ending in .py (for example main.py), and run it from your terminal with python main.py. No prior programming experience is assumed.
Running Python Code & Virtual Environments
Run your first Python program, experiment in the REPL, and keep each project isolated with a virtual environment so packages never clash.
Variables, Data Types & Type Casting
Store values in variables, learn Python’s core data types — numbers, strings, booleans, and None — and convert between them with type casting.
Working with Strings
Build and format text with f-strings, slice and index characters, and use the most common string methods to clean and search text.
Operators & Conditionals
Compare values, combine conditions with and/or/not, and branch your program with if, elif, and else.
Loops
Repeat work with for and while loops, generate number sequences with range, count with enumerate, and control loops using break and continue.
Lists, Tuples, Sets & Dictionaries
Master Python’s four core containers — when to use each — and write concise comprehensions to build new collections from old ones.
Functions, Lambdas & Scope
Package logic into reusable functions with parameters and return values, use default and keyword arguments, write one-line lambdas, and understand variable scope.
Exceptions
Handle errors gracefully with try/except, run cleanup with finally, raise your own exceptions, and catch the right error types.
Files, Context Managers & glob
Read and write files safely with the with statement, understand file modes, and find files by pattern using the glob module.
Modules, Packages & pip
Split code across files with imports, use Python’s standard library, and install third-party packages with pip — tracked in pyproject.toml.
Object-Oriented Programming
Model real-world things with classes — attributes, methods, the __init__ constructor, inheritance, and encapsulation.
Iterators, Generators & Decorators
Understand how iteration really works, produce values lazily with generators, and wrap functions with reusable decorators.
Regular Expressions
Search, match, and replace text patterns with Python’s re module — the practical patterns you’ll actually use.
Concurrency: Threads, Processes & async
Do many things at once — threads for waiting, multiprocessing for heavy computation, and asyncio for high-volume I/O — and learn why the GIL shapes the choice.
Type Hints & mypy
Add optional type hints to catch bugs early, document your code, and check everything with mypy before you run it.
Code Formatting with Ruff
Auto-format your code and catch common mistakes with Ruff — one fast tool that replaces black, isort, and flake8.
Testing with pytest
Write automated tests with pytest, check that errors are raised, reuse setup with fixtures, and run the same test over many inputs.
Building a Web API with FastAPI
Tie it all together — build a small JSON API with FastAPI using type hints for validation, path and query parameters, and request bodies.
Building for Scale: Observability & Resilience
Keep a busy service healthy. Measure it with metrics (prometheus-client), watch it with Prometheus, trace requests with OpenTelemetry, and survive failure with graceful degradation, rate limiting, and a circuit breaker.
Real-Time Data with WebSockets
Push live updates to the browser. Learn why WebSockets exist, add a WebSocket endpoint to FastAPI, broadcast to every connected client, and connect from the browser.
What to learn next
This course covers the Python language itself. To build real web apps and backend services, your next step is to learn Django — the most widely used Python framework for web apps, REST APIs, and database access. Finish Python first, then pick up Django.