Python Programming from Zero
Start with no programming experience and finish writing tested, well-structured Python programs that read files, call APIs and automate real tasks. Every module ends with something you can run.
What you will be able to do
- Write clear Python programs with functions, loops and the core data structures
- Organise code into modules and packages and manage dependencies with venv and pip
- Model problems with classes and dataclasses
- Read and write files, CSV and JSON, and call web APIs
- Test, debug and version your code with pytest and Git
Roadmap
Bar length shows each module's share of study time.
- 18h3 topics
Getting started
Install Python and write your first programs.
Show topicsNot startedRun Python from the terminal, the REPL and VS Code.
- Install Python 3 and check the version
- Start the REPL and try expressions
- Set up VS Code with the Python extension
- Run a script from the terminal
Work with ints, floats, strings and booleans and convert between them.
- Assign and reassign variables
- Use ints, floats, strings and booleans
- Check types with type()
- Convert between types with int(), str(), float()
Build small interactive programs that read input and format output neatly.
- Index, slice and call string methods
- Format output with f-strings
- Read user input with input()
- Build a small interactive calculator
- 212h5 topics
Control flow & functions
Make decisions, repeat work and name it.
Show topicsNot startedWrite if/elif/else branches with combined conditions and no redundant checks.
- Write if/elif/else branches
- Combine conditions with and, or, not
- Compare values and check membership
- Simplify redundant checks
Loop over sequences and ranges and stop or skip at the right moment.
- Loop over lists and strings with for
- Generate numbers with range()
- Write while loops with clear exit conditions
- Use break and continue correctly
- Iterate with enumerate() and zip()
Split a program into small functions with default and keyword arguments.
- Define functions with def and return
- Use default and keyword arguments
- Accept *args and **kwargs
- Write docstrings for your functions
- Refactor a script into small functions
Predict which variable a name refers to and avoid hidden global state.
- Trace local vs global scope
- Understand None as a return value
- Avoid mutating global state
- Rewrite a function to be pure
Replace long if/elif chains with readable match statements where they fit.
- Write a basic match/case statement
- Match on literals, tuples and classes
- Refactor an if/elif chain to match
Module resources:More control flow tools ↗ - 316h5 topics
Core data structures
Lists, dicts and friends: most of everyday Python.
Show topicsNot startedStore, slice, sort and unpack sequences confidently.
- Create, index and slice lists
- Append, insert and remove items
- Sort with sorted() and key functions
- Pack and unpack tuples
- Choose tuples for fixed records
Count, group and look up data with dicts and remove duplicates with sets.
- Create, read and update dicts
- Iterate over keys, values and items
- Count and group data with dicts
- Use sets to remove duplicates
- Apply set union and intersection
Turn simple build-a-list loops into list, dict and set comprehensions.
- Write list comprehensions with conditions
- Build dicts with dict comprehensions
- Build sets with set comprehensions
- Know when a plain loop is clearer
Explain why changing one list changed another and fix it with copies.
- Tell mutable from immutable types
- See aliasing with two names, one list
- Make shallow and deep copies
- Avoid mutable default arguments
Solve ten beginner exercises combining loops, lists and dicts without help.
- Solve list filtering exercises
- Solve counting and grouping exercises
- Solve string processing exercises
- Check solutions against edge cases
- Finish ten exercises without help
Module resources:Data structures tutorial ↗ - 410h4 topics
Files, errors & modules
Programs that survive real input and grow beyond one file.
Show topicsNot startedRead, process and write text files safely with context managers.
- Build paths with pathlib.Path
- Read text files with a with-block
- Write and append to files
- Process a file line by line
- List and filter files in a folder
Handle expected errors gracefully and raise clear errors of your own.
- Read a traceback and spot the error
- Catch specific exceptions with try/except
- Use else and finally blocks
- Raise errors with clear messages
- Define a custom exception class
Split a project into modules and import between them without circular imports.
- Import from the standard library
- Split code into your own modules
- Create a package with __init__.py
- Use the if __name__ == '__main__' guard
Create a venv per project and pin dependencies in a requirements file.
- Create and activate a venv
- Install packages with pip
- Freeze dependencies to requirements.txt
- Recreate an environment from requirements
- 510h3 topics
Object-oriented Python
Bundle data and behaviour when it helps.
Show topicsNot startedDesign a class with an initialiser, attributes and methods for a small domain.
- Define a class with __init__
- Add attributes and methods
- Create and use several instances
- Use class vs instance attributes
- Model a small domain with classes
Use __repr__, __eq__ and friends and choose composition over deep hierarchies.
- Subclass and override methods
- Call parent methods with super()
- Implement __repr__ and __eq__
- Prefer composition for has-a relationships
- Refactor a deep hierarchy to composition
Replace boilerplate classes with dataclasses and magic strings with enums.
- Convert a class to a dataclass
- Use defaults, frozen and field()
- Define an Enum for fixed choices
- Replace magic strings with enums
Module resources:Classes tutorial ↗ - 612h4 topics
Idiomatic Python & the standard library
Write Python that looks like Python.
Show topicsNot startedReach for Counter, defaultdict, itertools and datetime instead of reinventing them.
- Count items with Counter
- Group data with defaultdict
- Chain and group with itertools
- Parse and format dates with datetime
- Generate random samples with random
Write generators that process large data lazily.
- Understand the iterator protocol
- Write generator functions with yield
- Use generator expressions
- Process a large file lazily
Read and write simple decorators and custom with-blocks.
- Write a simple timing decorator
- Use functools.wraps correctly
- Write a context manager class
- Use contextlib.contextmanager
Annotate functions and classes so editors and type checkers catch mistakes.
- Annotate function parameters and returns
- Use list, dict and Optional hints
- Type a dataclass
- Run mypy or Pyright on a project
- 710h4 topics
Testing, debugging & Git
The habits that make code trustworthy.
Show topicsNot startedWrite unit tests with fixtures and parametrisation and run them on every change.
- Install pytest and write first tests
- Use assert and pytest.raises
- Share setup with fixtures
- Parametrise tests over many inputs
- Run tests on every change
Find bugs with tracebacks, breakpoints and pdb instead of random prints.
- Read tracebacks from bottom to top
- Set breakpoints in VS Code
- Step through code with pdb
- Inspect variables at a failure
Keep code consistent automatically with a linter and formatter.
- Install and run Ruff
- Auto-format code with ruff format
- Fix lint warnings automatically
Commit, branch and push your projects to GitHub.
- Initialise a repo and make commits
- Write a useful .gitignore
- Create and merge branches
- Push a project to GitHub
- Write a clear README
- 812h4 topics
Practical Python
Point your skills at real-world tasks.
Show topicsNot startedLoad, clean, summarise and export tabular and JSON data.
- Read CSV files with the csv module
- Clean and convert messy fields
- Summarise data with dicts and Counter
- Load and dump JSON files
Fetch data from a public API, handle errors and save the results.
- Make GET requests with requests
- Pass query params and headers
- Handle HTTP errors and timeouts
- Save API results to JSON
Turn a script into a CLI with arguments, options and help text.
- Parse arguments with argparse
- Add options, flags and defaults
- Write helpful usage text
- Package the script as a command
Write a script that renames, sorts or reports on files in a folder.
- Pick a repetitive task to automate
- List and rename files in bulk
- Sort files into folders by type
- Generate a summary report
- 912h2 topics
Capstone project
One complete program you built yourself.
Show topicsNot startedA short written spec with features, a dataclass model and the modules you will create.
- List must-have and nice-to-have features
- Sketch the dataclass model
- Plan modules and their responsibilities
A Git repo with modules, a dataclass model, JSON storage, an API call, tests and a README.
- Set up the repo, venv and Ruff
- Implement the dataclass model and storage
- Build the CLI commands with argparse
- Integrate a web API call
- Write pytest tests for core logic
- Write a README with usage examples