Python
You’ll answer every other question in Python, so this track makes sure you know what your code really does.
It starts from zero, with installing Python and running your first file, and ends with the internals interviewers like to ask about. Along the way: Git, pytest and pandas, which most Python job posts list.
How to use this roadmap
Section titled “How to use this roadmap”- Topics are in teaching order. “Builds on” links show what to know first, even from other tracks.
- New? Start at the top. Know some already? Jump to a level, or skip any topic you can already explain.
- Short on time? Tick “Asked often only” to see what interviews ask most.
- Your progress is saved in this browser.
Where it fits: Start here. You need nothing first.
46 topics in 4 levels, about 16 h of reading. With practice, plan 2 to 3 times that. 29 of 46 topics have lessons so far.
93 practice problems from this track’s lessons, in one list.
Foundations
Know this level already? Check what you know: 15 questions, about 8 minutes. Topics you get right are marked Known.
- 1. Install Python and run your first fileNot started
Set up Python, write a short file and run it from the terminal.
Start20 min read, about 1 h with practice
- 2. Variables, print() and input()Not started
Keep values in names, show them with print() and read what the user types.
Start15 min read, about 55 min with practiceBuilds on: Install Python and run your first file
- 3. Decisions and loops: if, for and whileNot started
Make decisions with if, and repeat steps with for and while loops.
Watch it run: Your own code
Start20 min read, about 1 h 10 min with practiceBuilds on: Variables, print() and input()
- 4. Numbers, strings, slicing and f-stringsNot started
Do maths, cut pieces out of text and build messages with f-strings.
Watch it run: Slices
Start20 min read, about 1 h 15 min with practiceBuilds on: Variables, print() and input()
- 5. Your first functions: def and returnNot started
Put steps in a function, pass values in and get a result back.
Watch it run: Your own code
Start15 min read, about 1 h with practiceBuilds on: Decisions and loops: if, for and while
- 6. list, tuple, dict and set, and what each operation costsAsked oftenNot started
The four everyday containers, when to use each, and which operations are fast.
Watch it run: Sets and lookups
Start25 min read, about 1 h 15 min with practiceBuilds on: Decisions and loops: if, for and while
- 7. How Python runs your codeNot started
What happens between pressing Run and seeing output.
Watch it run: Your own code · A line on Python’s stack
Start15 min read, about 1 h 15 min with practiceBuilds on: Your first functions: def and return
- 8. Names, objects and referencesAsked oftenNot started
A variable is a label stuck on an object, not a box that holds it.
Watch it run: Names and objects
Start15 min read, about 1 h 15 min with practiceBuilds on: list, tuple, dict and set, and what each operation costs
- 9. Mutable and immutable objectsAsked oftenNot started
Why changing a list changes it everywhere, but changing a string never does.
Watch it run: Names and objects
Start15 min read, about 1 h 15 min with practiceBuilds on: Names, objects and references
- 10. Functions, *args, **kwargs and the mutable-default trapAsked oftenNot started
Flexible arguments, and the classic bug when a default value is a list.
Start20 min read, about 1 h 15 min with practiceBuilds on: Your first functions: def and return · Mutable and immutable objects
- 11. Scope and the LEGB ruleNot started
How Python decides which variable a name means: local, enclosing, global or built-in.
Watch it run: Scope boxes
Start15 min read, about 1 h with practiceBuilds on: Functions, *args, **kwargs and the mutable-default trap
- 12. ComprehensionsAsked oftenNot started
Build a list, dict or set in one readable line instead of a loop.
Watch it run: Comprehensions
Start15 min read, about 1 h with practiceBuilds on: list, tuple, dict and set, and what each operation costs
- 13. ExceptionsNot started
Catch errors, raise your own and clean up safely with try, except and finally.
Watch it run: Exceptions
Start20 min read, about 1 h 15 min with practiceBuilds on: Your first functions: def and return
- 14. Files and pathlibNot started
Read and write files, with paths that work on Windows and Linux.
Watch it run: Files and paths
Start15 min read, about 1 h 15 min with practiceBuilds on: Exceptions
- 15. Modules, packages and virtual environmentsNot started
Split code into files, import it, and keep each project's packages separate.
Start20 min read, about 1 h 5 min with practiceBuilds on: Your first functions: def and return
- 16. Git for everyday work: commit, branch, merge, rebase, pull requestsNot started
Save versions of your code, work on branches and open pull requests.
Start25 min read, about 1 h 15 min with practiceBuilds on: Install Python and run your first file
Core
Know this level already? Check what you know: 13 questions, about 7 minutes. Topics you get right are marked Known.
- 1. Classes: inheritance, MRO, super() and dunder methodsAsked oftenNot started
Build your own types with classes, reuse code with inheritance, and add special methods like __str__.
Start40 min read, about 1 h 50 min with practiceBuilds on: Functions, *args, **kwargs and the mutable-default trap
- 2. @property, class methods and static methodsNot started
Run code when an attribute is read, and add methods that belong to the class.
Start15 min read, about 1 h with practiceBuilds on: Classes: inheritance, MRO, super() and dunder methods
- 3. DataclassesNot started
Simple data classes without repeated setup code: Python writes __init__, __repr__ and == for you.
Start15 min read, about 1 h with practiceBuilds on: Classes: inheritance, MRO, super() and dunder methods
- 4. Iterators and generatorsAsked oftenNot started
Produce values one at a time with yield, so huge data never has to fit in memory.
Watch it run: Generators
Start25 min read, about 1 h 30 min with practiceBuilds on: Comprehensions
- 5. ClosuresNot started
A function that remembers variables from the place it was created.
Watch it run: Scope boxes
Start15 min read, about 1 h 5 min with practiceBuilds on: Scope and the LEGB rule
- 6. Decorators, with arguments and functools.wrapsAsked oftenNot started
Wrap a function to add behaviour, like timing or retries, without changing its code.
Start25 min read, about 1 h 20 min with practiceBuilds on: Closures
- 7. Context managersNot started
The with statement: open something and always close it, even after an error.
Start15 min read, about 1 h 10 min with practiceBuilds on: Exceptions
- 8. collections, itertools and functoolsNot started
Ready-made tools like Counter, defaultdict, groupby and lru_cache that save you code.
Start25 min read, about 1 h 20 min with practiceBuilds on: Iterators and generators
- 9. Type hintsNot started
Label what a function takes and returns, so tools catch mistakes early.
Start15 min read, about 1 h 10 min with practiceBuilds on: Functions, *args, **kwargs and the mutable-default trap
- 10. is vs ==, shallow vs deep copyAsked oftenNot started
Same object or equal value? And why copying a list of lists can surprise you.
Start15 min read, about 1 h with practiceBuilds on: Mutable and immutable objects
- 11. LoggingNot started
Record what your program does with levels and handlers, instead of print().
Start15 min read, about 1 h with practiceBuilds on: Modules, packages and virtual environments
- 12. pytest basicsNot started
Write small tests with plain assert and run them all with one command.
Start20 min read, about 1 h 20 min with practiceBuilds on: Functions, *args, **kwargs and the mutable-default trap
- 13. pandas basics: DataFrames, filtering, groupby and mergeNot started
Load a table, filter rows, group and join: the everyday pandas moves.
Start30 min read, about 1 h 20 min with practiceBuilds on: Comprehensions
Advanced
- 1. Memory management and garbage collectionComing soon
How Python frees memory: reference counts, plus a collector that cleans up cycles.
20 min readBuilds on: Names, objects and references
- 2. The GIL and free-threaded buildsAsked oftenComing soon
Why only one thread runs Python code at a time, and the new builds that lift that limit.
20 min read
- 3. Threading vs multiprocessing vs asyncioAsked oftenComing soon
Which tool for waiting on the network, and which for heavy number crunching.
25 min readBuilds on: The GIL and free-threaded builds
- 4. asyncio in depth: event loop, tasks, gather, cancellation, timeoutsAsked oftenComing soon
Run many network calls at once with async and await, and stop them cleanly.
40 min readBuilds on: Threading vs multiprocessing vs asyncio
- 5. DescriptorsComing soon
The mechanism behind @property: objects that control how an attribute is read or set.
20 min readBuilds on: @property, class methods and static methods
- 6. MetaclassesComing soon
Classes that make classes, and the simpler tools to use instead most of the time.
20 min readBuilds on: Classes: inheritance, MRO, super() and dunder methods
- 7. __slots__Coming soon
Save memory on many small objects by fixing their attributes when the class is made.
10 min readBuilds on: Classes: inheritance, MRO, super() and dunder methods
- 8. ABCs vs ProtocolsComing soon
Two ways to say "this object must have these methods", and when each fits.
15 min readBuilds on: Type hints
- 9. Packaging with pyproject.tomlComing soon
Turn your code into a package that others can install with pip.
20 min readBuilds on: Modules, packages and virtual environments
- 10. Profiling and optimizationComing soon
Measure where the time goes before you try to speed anything up.
20 min readBuilds on: Functions, *args, **kwargs and the mutable-default trap
- 11. pytest fixtures, parametrize and mockingComing soon
Share test setup, run one test with many inputs, and fake slow or outside parts.
25 min readBuilds on: pytest basics
Interview-ready
- 1. CPython internals that get asked: dict, list, interning, disComing soon
How dict, list and small numbers work inside Python, and reading bytecode with dis.
25 min readBuilds on: Memory management and garbage collection
- 2. Predict-the-output puzzlesAsked oftenComing soon
Short tricky snippets: say what they print before you run them.
20 min readBuilds on: is vs ==, shallow vs deep copy
- 3. Pythonic refactorsComing soon
Turn code that works but reads badly into clear Python, in the usual Python style.
20 min readBuilds on: Comprehensions
- 4. Design patterns in PythonComing soon
The few design patterns worth knowing, written the light Python way.
25 min readBuilds on: Classes: inheritance, MRO, super() and dunder methods
- 5. Security mistakes: eval, pickle, injectionComing soon
Common ways Python code gets attacked, and the safe alternatives.
15 min read
- 6. Coding set: LRU cache, retry with backoff, thread-safe counter, rate-limited client, bounded async fetcherAsked oftenComing soon
Classic "build it in Python" questions: an LRU cache, retries, a thread-safe counter and more.
45 min readBuilds on: Decorators, with arguments and functools.wraps