Articles
The lessons from the videos, written down, with code you can copy. Filed by language, then by level, in the order they are taught.
Python
From the first line to data structures and algorithms, in the order the videos teach them.
Beginner24 articles
-
Lesson 14 min read
Python Hello World: your first program, step by step
Install Python 3.14, run it two ways, and read an eleven-line program one line at a time.
-
Short note2 min read
Python IndentationError explained: whitespace is syntax
Why four spaces decide what your program does, shown with one line that moves.
-
Short note2 min read
Python REPL vs .py file: two ways to run Python
When to type into the interactive shell, when to save a file, and what Python 3.14 added to the shell.
-
Lesson 25 min read
Python variables and data types: int, float, str, bool, None
The five basic types, how to ask Python what type a value is, and how to turn one type into another.
-
Short note2 min read
Python int overflow: why 2 ** 1000 just works
Most languages keep a whole number in 64 bits and overflow past it. A Python int has no limit, and the reason also explains why floats still do.
-
Short note2 min read
Python type() function: why 3, 3.0 and "3" are different
Three values that look alike are an int, a float and a str. type() shows the difference, and mixing them shows why it matters.
-
Lesson 35 min read
Python if else and loops: if, elif, for, while, break, continue
How a program decides with if, elif and else, repeats with for and while, and stops or skips a round with break and continue.
-
Short note2 min read
Python chained comparison: 0 < x < 10 just works
In most languages that line is a bug. In Python it is one test that means exactly what it says, and this note shows how Python reads it.
-
Short note2 min read
Python for else: the else that means no break
A Python for loop can have an else block, and it does not mean what you think. It runs only when the loop finished on its own, with no break.
-
Lesson 45 min read
Python strings: indexing, slicing, methods and f-strings
Pick characters out of a Python string, slice pieces off it, clean it up with methods like strip and split, and build new text with f-strings.
-
Short note2 min read
Python f-string debugging: print the name and value with =
Put an equals sign after a name inside an f-string and Python prints the name, the equals sign and the value, so debug prints never need the name typed twice.
-
Short note2 min read
Reverse a string in Python with slicing: [::-1]
Slice a Python string with a step of minus one and you get it backwards, with no loop and no function. The same trick checks for a palindrome.
-
Lesson 55 min read
Python lists: index, slice, append, pop and sort
Build a Python list, index and slice it, grow and shrink it with append, insert and pop, sort it, and learn what each move costs.
-
Short note2 min read
Python list insert at the front is slow: use deque appendleft
nums.insert(0, x) shifts every item in a Python list one place right, so it gets slower as the list grows. A deque adds to the front without moving anything.
-
Short note2 min read
Python negative indexing: get the last item with nums[-1]
A negative index counts from the end of a Python list, so nums[-1] is always the last item, with no len() needed.
-
Lesson 65 min read
Python tuples and sets: unpacking, swapping and removing duplicates
Make a Python tuple, unpack it, swap two variables in one line, and use a set to remove duplicates and check membership in O(1).
-
Lesson 74 min read
Python dictionaries: keys, values, get, items and counting
Store Python values by key in a dictionary, look them up, add new ones, loop over them with items(), avoid a KeyError with get(), and count words.
-
Lesson 84 min read
Python functions: def, return, default arguments and *args
Write your own Python functions with def, return a result, use default and keyword arguments, understand local variables, and collect any number of arguments with *args.
-
Lesson 94 min read
Python list comprehensions: lists, dicts, sets, if, any and all
Build a Python list, dictionary or set from another one in a single line, filter it with if, test it with any and all, and know when a plain loop is clearer.
-
Lesson 104 min read
Python errors and exceptions: try, except, else, finally, raise
Catch a Python error with try and except instead of crashing, run cleanup with finally, raise your own errors, and read a traceback from the bottom up.
-
Lesson 114 min read
Python read and write files and JSON: open, pathlib, json.dump and json.load
Read and write files in Python with open and a with block, build paths with pathlib, and save a dictionary as JSON with json.dump and get it back with json.load.
-
Lesson 124 min read
Python modules, import and uv: the standard library, packages and pyproject.toml
Use code other people wrote with import, from and as, install packages with uv add, keep each project in its own virtual environment, and tidy it with pyproject.toml and ruff.
-
Lesson 134 min read
Python classes for beginners: __init__, self, methods and @dataclass
Build your own type with class, store data on it with __init__ and self, give it behaviour with methods, print it clearly with __repr__, and see the @dataclass shortcut.
-
Lesson 144 min read
Python to-do list project for beginners: lists, dicts and JSON
Build a small Python to-do app from what you already know: tasks as a list of dictionaries, saved to a JSON file, loaded back with try and except, and printed with enumerate.
Intermediate17 articles
-
Lesson 15 min read
Python Big O notation: measure speed with timeit
What Big O means in Python, how to measure growth with timeit at three sizes, the five curves you meet most, and what list, dict and set operations cost.
-
Lesson 24 min read
Python iterators and generators: yield, next and itertools
What a for loop really does with iter and next, how yield turns a function into a generator, why a generator expression uses almost no memory, and the lazy tools in itertools.
-
Lesson 34 min read
Python closures and scope: LEGB, nonlocal and late binding
Where Python looks for a name, how a function inside a function remembers its variables, how nonlocal changes them, and why lambdas made in a loop all return the same value.
-
Lesson 45 min read
Python decorators explained: @wraps, arguments and lru_cache
What the at sign above a function really does, how to write a decorator, how functools.wraps keeps the name, how to give a decorator arguments, and how lru_cache makes recursive Fibonacci instant.
-
Lesson 54 min read
Python classes explained: dunder methods, property and super
How a Python class prints itself with dunder methods, hides a function behind an attribute with @property, builds objects with @classmethod, and extends a parent class with super().
-
Lesson 64 min read
Python type hints explained: str, list[int] and int | None
How to add type hints to a Python function, describe a list with list[int], mark a value that might be None with int | None, and what a type checker does with the hints.
-
Lesson 74 min read
Python stacks and queues: list, deque and why pop(0) is slow
What a stack and a queue are, how to build a stack from a list and a queue from a deque, and why pop(0) on a list costs O(n) while popleft on a deque does not.
-
Lesson 84 min read
Python linked lists from scratch: Node class and head
How a linked list works in Python: a Node class that holds a value and a link, the head, the None that ends the chain, how to walk it, and why adding at the front is O(1) but finding an item is not.
-
Lesson 94 min read
Python recursion explained: call stack and base case
How recursion works in Python: a function that calls itself on a smaller problem, the call stack that holds the waiting calls, the base case that stops them, and the RecursionError you get without one.
-
Lesson 104 min read
Python binary search explained: low, high and mid
How binary search works in Python: check the middle of a sorted list, drop half, move low and high past the middle, and why a million items take about 20 steps.
-
Lesson 114 min read
Python sorting algorithms: bubble sort, merge sort, sorted()
How sorting works in Python: bubble sort swaps neighbours in O(n squared), merge sort splits and merges in O(n log n), and sorted() with key does the job for you in real code.
-
Lesson 125 min read
Python hash tables: how a dict finds a key so fast
How a Python dict works inside: the key becomes a hash, the hash picks a slot, so lookup is O(1). Collisions, why a list cannot be a key, and how a set fits in.
-
Lesson 134 min read
Python heapq: heaps and priority queues explained
How a Python heap always gives you the smallest item first. The heap rule, pop and push at O(log n), heapq on a plain list, and a tiny task scheduler with its real output.
-
Lesson 145 min read
Python trees and traversal: binary trees and in-order walk
How a Python binary tree is built from nodes, what makes it a search tree, and how an in-order walk visits every node in sorted order. A small recursive function with its real output.
-
Lesson 155 min read
Python HTTP and JSON APIs: fetch data with urllib
How to call a web API in Python with only the standard library: send a request with urllib, turn the JSON response into a dictionary, and handle a bad address, a down network or a 404. One short script with its real output.
-
Lesson 164 min read
Python testing with pytest: write and run tests
How to test Python code with pytest: how it finds tests by name, how a test is a plain assert, what a failure shows, and how to run one test on many inputs with parametrize. One short test file with its real output.
-
Lesson 174 min read
Python packaging with uv: build and publish a package
How to package Python code with uv: start a package with uv init, name a command in pyproject.toml, build a wheel with uv build, and publish it to PyPI. One small function with its real output.
Advanced8 articles
-
Lesson 14 min read
Python graphs: BFS and DFS explained, with the shortest path
How to store a graph in Python as an adjacency list, find the shortest path with breadth first search and a deque, and when depth first search is the better walk. One small function with its real output.
-
Lesson 27 min read
Python Dijkstra's algorithm with heapq: the cheapest path in a weighted graph
How to find the cheapest path through a weighted graph in Python with Dijkstra's algorithm and heapq, how relaxation works, why a negative weight gives a wrong answer, and how Bellman-Ford fixes it. Two short functions with their real output.
-
Lesson 36 min read
Python dynamic programming: memoisation, tabulation and lru_cache
How dynamic programming works in Python: why recursive Fibonacci repeats work, memoisation with lru_cache, tabulation with a table, then 0/1 knapsack, the longest increasing subsequence and edit distance, each with real output.
-
Lesson 410 min read
Python trie and union find: prefix search, autocomplete and Kruskal
How to build a trie in Python for prefix search and autocomplete, then union find with path compression and union by size, and use it to run Kruskal's algorithm for a minimum spanning tree. Four short programs with their real output.
-
Lesson 59 min read
Python asyncio: async, await, gather and timeouts explained
How Python asyncio works: the event loop, async def and await, running many things at once with create_task and gather, putting a limit on the wait with timeout, keeping tasks safe with TaskGroup, why a blocking call freezes everything, and the Python 3.14 tools that show running tasks. Three short programs with their real output.
-
Lesson 67 min read
Python threads vs processes: the GIL, locks and free threading
How Python threads, processes and subinterpreters differ: what the GIL is, why threads help with waiting but not calculating, how ThreadPoolExecutor and ProcessPoolExecutor compare, how a Lock stops a race condition, and what the Python 3.14 free-threaded build changes. Three short programs with their real output.
-
Lesson 78 min read
Python memory management: reference counting, garbage collection and __slots__
How Python frees memory: reference counting with sys.getrefcount, reference cycles and the gc module, why sys.getsizeof is shallow and tracemalloc is not, what __slots__ saves, how small integers and interned strings are shared, and how weakref works. Four short programs with their real output.
-
Lesson 87 min read
Python descriptors and metaclasses explained: property, __set_name__ and __init_subclass__
How Python descriptors work: __get__ and __set__ on the class, how property is built from one, a reusable Positive descriptor with __set_name__, data versus non data descriptors, __init_subclass__ for a plugin registry, and when a metaclass is the right tool. Five short programs with their real output.