Lessons88
0/88 modules masteredGetting Started
10 lessons · 6 hrRun your first program, then variables, decisions, loops, functions and decorators. Everything else is built on these.
Your First Python Program
Up NextWrite and run your first Python program in the next 60 seconds — nothing to install.
Variables, Types & Operators
A variable is a name for a value. Getting names and types right is most of what makes a program readable.
Mini-Project: Mad Libs Generator
You'll build a Mad Libs game.
Control Flow: Making Decisions & Repeating
Three keywords — if, for and while — are what let a program make decisions and repeat work. Almost everything else is built on them.
Functions, Part 1: Writing and Calling Them
Write a piece of code once, give it a name, and use it anywhere. Functions are how programs stop repeating themselves.
Mini-Project: Number Guessing Game
You'll build a number guessing game — the computer picks a secret number, and you keep guessing until you get it.
Mini-Project: FizzBuzz
You'll build FizzBuzz, a classic exercise that combines loops, modulo, and ordered if/elif.
Functions, Part 2: Functions as Values
What happens when one function calls another, why a function can remember the variables it was born in, and what it means to hand a function to another function.
Decorators: Functions That Wrap Functions
Every @app.get(...) in FastAPI and every @pytest.fixture is a decorator: a function that takes a function and hands back a better one.
Mini-Project: Tip Calculator
You'll build a tip calculator — the kind you actually use at restaurants.
Working with Data
8 lessons · 5 hrLists, how Python names and copies values, dictionaries and the collections module. The containers you will reach for in almost every program.
Lists, Tuples, Dicts & Sets
Lists, tuples, dicts and sets. Picking the right one is most of what makes code fast and readable.
List Comprehensions: Python's Superpower
Build a list, dict or set from another collection in one readable line.
Python's Memory Model: Objects, References & Identity
The #1 source of "why is my function mutating my list?!" bugs is misunderstanding Python's reference model.
Mini-Project: Grade Statistics
Build a grade statistics calculator: mean, minimum, maximum, pass rate and top scorers from a list of grades.
Dictionaries, Part 1: Lookup and How It Works
Dictionaries are the most-used data structure in Python — every object, every module namespace, every JSON response from an API is a dict under the hood.
Dictionaries, Part 2: Comprehensions, JSON and Merging
Comprehensions, nested dicts and JSON, why dicts keep their order, and the merge operators.
The collections Module: Python's Supercharged Data Structures
Counter, defaultdict, deque, namedtuple — these are the data structures that separate hobbyist scripts from production code.
Mini-Project: Word Counter
Build a word frequency counter: a dict as a tally board, then sorted by count.
Working with Text
3 lessons · 2 hrSlicing, formatting and encoding strings, the text handling that data and language work both need.
Strings, Part 1: Slicing, Methods and Formatting
Names, messages, addresses, whole documents — text is most of what programs actually handle.
Strings, Part 2: Encoding, Performance and Patterns
What a character really is in memory, why building text in a loop is slow, and where a regular expression fits — three things that separate working with text from fighting it.
Mini-Project: Password Strength Checker
Build a password strength meter: check rules with string methods, score them, and say what is missing.
Programs That Don't Break
11 lessons · 6 hrHandling errors, generators and context managers, reading and writing files, regular expressions, modules and environments, version control, secrets and calling an API. This is where scripts become tools.
Error Handling & Debugging: Don't Panic at Red Text
Senior engineers don't write fewer bugs. They read tracebacks faster, and a traceback names the exception, the file, the line, and how you got there.
Mini-Project: Robust Calculator
You'll build a calculator that keeps running when the input is bad. Type "ten" instead of 10? It says "please enter a number" and asks again. Divide by zero?
Generators & Context Managers
Generators hand you values one at a time, and the with statement guarantees cleanup. Both are built on pausing a function with yield.
Files, Paths, CSV, JSON Lines and Dates
Read and write text, CSV and JSON Lines files safely, build paths with pathlib, handle timestamps correctly and survive bad rows.
Mini-Project: Todo App
You'll build a CLI todo app, a classic first project, written in pure Python with real file persistence.
Regular Expressions: Match, Capture and Parse
Write regex patterns from literal text, classes, quantifiers and groups, pick the right re function, and parse a training log line into a dictionary.
Regular Expressions in Practice: Clean, Validate and Stay Safe
Clean raw text with a chain of substitutions, validate ID formats, use lookahead, and recognise a regex pattern that can become dangerously slow.
Modules, Packages & Environments with uv
Split your code into importable files, then create a project environment, install packages and share the setup with uv, while still reading the pip and venv commands every tutorial shows.
Git Basics: History, Branches and Keeping Secrets Out
Use git to save a history of your project, undo mistakes safely, work on a branch, and keep secrets and large files out of the repository.
Environment Variables & Secrets: Never Hardcode API Keys
A single leaked OPENAI_API_KEY in a public GitHub repo can be found and abused by bots soon after the push.
Calling APIs in Python: requests, JSON & Authentication
How your Python code fetches data from, and sends data to, another program over the internet.
Objects and Types
7 lessons · 5 hrClasses, type hints and testing, inheritance, dataclasses and Python's data model. How larger programs are organised.
Classes: Bundling Data with the Code That Uses It
Write a class that holds its own data and the methods that use it, print it readably, validate it with a property, and build bigger objects out of smaller ones.
Mini-Project: Bank Account Class
You'll build a BankAccount class in 25 minutes — the canonical OOP example, but written so it actually feels useful.
Type Hints and Testing: assert and pytest Basics
Annotate functions with modern type hints, check them with mypy, and write your first pytest tests with assert, pytest.raises and parametrize.
The Python Data Model: Make Your Classes Print, Add and Compare
Python's built-in syntax calls special methods on your object, so you can give your own Vector class a readable print, +, *, == and ordering, and make it work in sets and dicts.
The Python Data Model, Part 2: Sequences, Iteration and Descriptors
Give your own Dataset class len(), indexing, slicing, loops and truthiness, make an object callable like model(x), and see how a method gets its self through __get__.
Advanced OOP, Part 1: Inheritance, MRO & ABCs
Build one small family of model classes and use inheritance, super(), the method resolution order, abstract base classes, context-manager and decorator classes, and custom exceptions to keep it correct.
Advanced OOP, Part 2: Dataclasses, Enums & Protocols
Write records with @dataclass, replace magic strings with Enum, and describe interfaces with Protocol, the same typed-class habits that Pydantic models and FastAPI schemas build on.
Data and Machine Learning Libraries
6 lessons · 5 hrNumPy, pandas, charts, scikit-learn and databases. The libraries every data and ML project uses.
NumPy: Arrays for ML Data
Build and reshape NumPy arrays, centre a feature matrix with broadcasting, select rows with boolean masks, and draw repeatable random numbers.
Pandas Essentials: Tables for ML Data
Read a CSV or Parquet file into a pandas DataFrame, select and filter rows, handle missing values, and summarise groups with groupby.
Data Visualization with Matplotlib
The universal language of scientific plots — and the foundation Seaborn and pandas plotting are built on.
Pandas Advanced: merge, pivot, apply, and Time Series
The difference between a junior and a senior data engineer is .merge() semantics — knowing why your row count exploded after a "harmless" join.
Python for Machine Learning: The scikit-learn Workflow
Train, score, cross-validate and save a scikit-learn model, and scale features without leaking test data.
Databases in Python: sqlite3, Safe Queries and SQLAlchemy
Store experiment runs in a SQLite database from Python, query them with safe parameters, keep failed writes from leaving half-saved data, and move results to and from pandas.
Quality and Concurrency
2 lessons · 2 hrTesting with pytest and running work in parallel with async code.
Testing with pytest: Fixtures, Mocks and Coverage
Write pytest tests that share setup with fixtures, read and write temporary files, fake an HTTP call so nothing touches the network, and read a coverage report without trusting it too much.
Async/Await & Concurrency: Parallel Python
A single async worker can serve thousands of concurrent I/O-bound requests. asyncio underpins the modern Python web stack — FastAPI, Starlette, aiohttp, Quart.
Building and Shipping
3 lessons · 3 hrA web service with FastAPI, reading somebody else's codebase, and the logging, configuration and packaging a real service needs.
Building APIs with FastAPI: From Endpoint to Deployment
FastAPI is the default choice for typed Python APIs: automatic OpenAPI docs, Pydantic-typed everything, async-native
Reading Real Python Code: A FastAPI Service End-to-End
The gap between "I know Python syntax" and "I can read a codebase" is real. A skim-then-dive method, practised on one complete FastAPI service.
Production Python: Logging, Config, CLIs and Packaging
Turn a script into something you can run unattended and ship: log with the logging module, load typed configuration, add an argparse command line, and package it with pyproject.toml.
Your First AI Application
4 lessons · 6 hrCall a language-model API the way a real program does, build projects that combine everything, finish with the capstone, then use the visual tour as a review map.
Calling an LLM API from Python: Messages, Retries, Streaming and Cost
Build a small ChatSession class that keeps history, trims it, retries rate limits, streams replies, returns validated JSON and tracks token cost, and test it without calling any model.
Python Projects
Two projects that go beyond the mini-projects: a pandas data dashboard and an OOP quiz game with a decorator and a leaderboard, plus a list of ways to extend the earlier minis.
Capstone: Build a Command-Line LLM Assistant
Build one complete command-line assistant that calls a language model with retries, streaming, checked JSON and cost tracking, and prove it works with tests that need no API key.
Python Visual Tour: Every Concept, Animated
A guided tour of every Python concept this track covers, in the order you'll learn them.
Optional Depth: Classic Algorithms and How Python Works
Optional34 lessons · 31 hrA start-here lesson on cost and Big-O, then searching, stacks and queues, recursion, linked lists, array patterns, hash tables, sorting, trees, heaps, graphs and backtracking, then advanced DP, shortest paths, Union-Find and spanning trees, greedy algorithms, divide and conquer, asymptotics and bit manipulation, then expert topics (balanced trees, range queries, string algorithms, probabilistic structures, advanced graphs, storage structures, vector search, NP-hardness and CPython containers), a look inside CPython, and last a problem-solving playbook. Classic computer-science depth; you do not need it to finish the track.
Algorithms and Data Structures: Start Here
What a data structure and an algorithm are, what n and log n mean, how to read Big-O in five lines, a map of the lessons ahead, and a one-page cost cheat sheet for list, dict, set, deque, heap and sorted.
Big-O and searching
Measure how running time grows with the input, name the growth as Big-O, search a sorted list with binary search and bisect, and spot where that cost hides in ML code.
Stacks and queues
Stacks and queues: last in first out and first in first out, with deque, circular queues, the monotonic stack, and real uses such as undo, rate limiting and breadth-first search.
Recursion & Dynamic Programming, Part 1: The Idea
The call stack, base and recursive cases, why naive recursion goes exponential, and the two ways out of it — memoization and tabulation — plus the 5-question DP framework.
Linked Lists, Part 1: Singly Linked Lists
Build a singly linked list from node objects, reverse it, find its middle and detect a cycle, then measure it against list and deque to see when it is the wrong choice.
Linked Lists, Part 2: Doubly Linked, Merge & LRU Cache
Build on Part 1's singly linked list: doubly linked lists with prev/next pointers, merging two sorted lists, full LRU cache, and recursive reversal.
Array Patterns: Two Pointers, Sliding Window and Prefix Sums
Three habits that turn nested loops over a list or string into one pass: two pointers from the ends or in the same direction, a sliding window of fixed or variable size, and prefix sums with a dict, with a rule for choosing between them.
Build a Hash Table
Build a hash table from scratch: a hash function, collisions, separate chaining, open addressing with tombstones and resizing, see why doubling gives amortized O(1), then compare it with CPython's dict and choose between a dict, a set and a sorted list.
Sorting Algorithms
Sort by hand with bubble, selection and insertion sort, then build merge sort and quick sort, see why no comparison sort beats n log n, break that limit with counting and radix sort, and learn what Python's sorted does.
Binary Search Patterns
Write binary search with an invariant so it never goes off by one, find the first and last copy of a value with lower and upper bound, search a rotated list, search on the answer with a yes or no test, search real numbers, and find a peak.
Trees & BST, Part 1: Binary Trees & Traversals
Trees from first principles — terminology, the TreeNode class, BST insert/search, and all four traversals (BFS, inorder, preorder, postorder) recursively and iteratively.
Trees & BST, Part 2: Balanced Trees & Trie
BST deletion with all three cases, the famous cross-level validation bug, self-balancing AVL/Red-Black trees, Tries for autocomplete, and expression trees evaluated by postorder.
Heaps
A heap keeps the smallest item one step away without sorting anything else: the array layout, heapq, the max-heap trick, building one from scratch, and the classic top-K problems.
Graphs
Graph vocabulary, adjacency lists, matrices and edge lists, BFS and DFS and which question each one answers, the fewest-edges route, and counting connected components. Cheapest routes and Union-Find have their own lessons.
Backtracking: Try, Check, Undo
Solve subsets, permutations, combinations, combination sum, N-Queens and word search with one choose, explore, un-choose template, cut dead branches early, count the work honestly, and know when dynamic programming is the better tool.
Dynamic Programming, Part 2: The Classic Problems
Five classic problems (coin change, knapsack, longest common subsequence, longest increasing subsequence and edit distance) worked with the 5-question framework, plus when to pick memoization or tabulation.
DP Patterns, Part 2: Grids, Intervals, Bitmasks and Trees
A repeatable method for designing a dynamic program, then grid DP, longest increasing subsequence in O(n log n), interval DP, bitmask DP for a small travelling salesman, DP on trees, rolling rows, rebuilding the real answer, and how to choose between DP, greedy, backtracking and plain recursion.
Shortest Paths: Dijkstra, Bellman-Ford, A* and More
Find the cheapest route through a graph with BFS, Dijkstra and a heap, topological sort and DAG paths, Bellman-Ford for negative edges, Floyd-Warshall for all pairs, 0-1 and multi-source BFS, and A* on a grid, then pick the right one from a table.
Union-Find and Minimum Spanning Trees
Keep track of which items are in the same group with a parent array, make it almost O(1) with path compression and union by rank, use it for dynamic components, cycles, islands and merged accounts, then build the cheapest network with Kruskal and Prim.
Greedy Algorithms: Take the Best Now, Then Prove It Is Safe
Learn what makes a greedy rule correct, prove one with the exchange and stays-ahead arguments, solve interval, Huffman, jump game, gas station and meeting room problems, see greedy fail on knapsack and coins, and decide between greedy and dynamic programming.
Divide and Conquer: Split, Solve, Combine
Split a problem into smaller copies of itself, write its cost as a recurrence, solve it with a recursion tree and the master theorem, then use the idea for fast powers, maximum subarray, counting inversions, quickselect, Karatsuba multiplication and the closest pair of points.
Asymptotics and amortized analysis
Define O, Omega, Theta and little-o with the c and n0 picture, prove bounds by choosing c and n0, solve recurrences by substitution, count space including the recursion stack, and analyse amortized cost with the aggregate, accounting and potential methods.
Bit Manipulation: Working With Individual Bits
Read numbers in binary, use & | ^ ~ << >> with hand traces, understand Python's unlimited integers and negatives, master the test, set, clear and toggle tricks and x & (x - 1), count bits, use XOR, enumerate subsets with a bitmask, and see bit packing, quantization and bitsets at work.
Balanced Trees: AVL, Red-Black and B-Trees
Why a plain search tree collapses on sorted input, how AVL rotations keep the height logarithmic with a proof, the red-black idea, and why databases use wide B-tree nodes to cut disk reads.
Range Queries: Prefix Sums, Sparse Tables, Fenwick and Segment Trees
Answer many range sum and range minimum questions while the data changes: prefix sums and why updates break them, the sparse table, the Fenwick tree and its lowbit trick, the segment tree with lazy propagation, a sqrt decomposition note, and a decision table.
String Algorithms: KMP, Rolling Hash, Tries and Suffix Arrays
Search text for a pattern without re-reading it: the naive worst case, KMP and its prefix table, Rabin-Karp and rolling hashes, the Z-algorithm and Horspool skipping, Aho-Corasick for many words, suffix arrays, palindromes, and a pointer to edit distance.
Probabilistic Structures: Bloom Filters, Count-Min, HyperLogLog, Sampling and Consistent Hashing
Trade a small, controlled chance of error for a huge saving in memory: Bloom filters with their false-positive formula and sizing, count-min sketches, HyperLogLog, reservoir sampling and consistent hashing with virtual nodes, all built with replayable hashes.
Advanced Graphs: Components, Bridges, Matching and Max-Flow
Find strongly connected components with Kosaraju, bridges and articulation points with low-links, test for two-colorability, match items with augmenting paths, and compute max-flow and min-cut with Edmonds-Karp, with the cost and the reason for each.
Storage Structures: B+ Trees, Skip Lists and LSM Trees
Why disks change the rules, how a B+ tree turns a billion keys into a handful of block reads, how a skip list gets log n from coin flips, and how a log-structured merge tree with a write-ahead log, Bloom filters and compaction trades read cost for fast writes.
Vector Search: Nearest Neighbors at Scale
Find the closest vectors to a query: distance and cosine similarity, exact search and its O(n d) cost, the curse of dimensionality, k-d trees, random-hyperplane hashing, clustering lists, navigable graphs (HNSW), quantization, and how to measure recall against speed.
NP-Hardness and Approximation: When Exact Is Too Slow
Tell easy problems from hard ones: P, NP and reductions in plain words, the classic NP-complete problems, pseudo-polynomial subset sum and knapsack, then the three ways out: exact exponential search, approximation with proofs, and heuristics.
CPython Container Internals: list, dict, set, heapq, sorted and bisect
See how CPython builds list, tuple, dict, set, deque, heapq, sorted and bisect: over-allocation, the hash and equality contract, a heap stored in a list, runs and galloping in Timsort, and what interning promises, each shown by counting.
How CPython Works: Bytecode, Objects, the Cycle Collector and the GIL
Read the bytecode CPython runs with dis, explain what a Python object is, find reference cycles, and say what the GIL and the free-threaded build change.
The Problem-Solving Playbook: How to Choose the Technique
Read the constraints to find the target cost, follow a six-step method and a decision flow, match signals to every technique in Part 10, debug with a tiny counter and a stress test, avoid the common traps, and finish with five mixed problems where you must name the technique first.
Practice labs
22 interactive labs — hands-on exercises for this track
Loop Visualizer
You're a factory robot repeating the same task on an assembly line — watch how loops automate repetitive work
List Slicing
You have a playlist of 50 songs — grab just tracks 10 through 20 with a single slice expression
Sorting Algorithms
You're organizing a library of 10,000 books — which sorting method is fastest?
Big-O Complexity
Searching 1,000 users is fast — but what happens when you hit 1 million? See how algorithms scale
Hash Table Visualizer
Type a key, watch the hash compute, see the bucket fill. Feel collisions and load factor in real time.
Recursion Tree Explorer
Visualize the call tree of naive Fibonacci. Duplicate subproblems glow red — toggle memoization and watch exponential collapse to linear.
DP Table Animator
Watch a Longest Common Subsequence DP table fill cell by cell with dependency arrows, then a green traceback reveals the hidden subsequence.
Class Hierarchy & MRO
Click through a Python class inheritance tree and watch the MRO (C3 linearization) animate as methods resolve up the chain.
Generator & Iterator Flow
Step through a Python generator one yield at a time, see the frozen frame, and compare memory against its eager-list twin.
Decorator Flow Animator
Watch a value flow through stacked Python decorators — peel in on the way down, wrap out on the way back — and see why decorator order matters.
List vs Array Complexity
Watch Python list operations animate — append, insert, delete, access — and see how Big-O emerges from your own clicks.
Async/Await Flow
Race three HTTP requests sync vs async. Watch the event loop schedule, yield, and resume — three 1-second requests finish in 1 second, on a single thread.
Context Manager Visualizer
Step through a `with` statement for file I/O, DB transactions, and locks. Watch __enter__ acquire, the body run, and __exit__ clean up — even when the body raises.
Exception Chain Visualizer
Step through nested try/except as an error bubbles up. Watch the call stack unwind, the new exception chain via __cause__, and Python's 'During handling...' traceback form.
Type Hints & Static Analysis
Toggle type annotations and watch a mypy-like checker catch bugs before runtime — the kind you'd otherwise hit in production.
Dataclasses Visualizer
Compare hand-written class vs @dataclass. Toggle frozen/slots/default_factory to see generated boilerplate update live.
Protocols & Structural Typing
Compare ABC vs Protocol typing side-by-side. See why Protocol = duck typing + static verification.
Itertools Explorer
Visualize chain, cycle, islice, takewhile, combinations, groupby — one lazy pull at a time.
Pathlib Visualizer
Traverse a mock filesystem with pathlib — glob, parent, path joining, read_text, exists.
pytest Visualizer
Parametrize tests, inject bugs, add fixtures, watch coverage light up.
Python String Formatting
Compare %-old / .format / f-strings side-by-side. Drive format specs to see padding, precision, thousands separators live.
Python Logging & Debugging
Set root level, swap handlers, toggle JSON formatter, walk through pdb.set_trace() with live locals.
Test your knowledge
1229 questions across 88 modules — check how well you understood this track.