Python

A free, complete Python course from beginner to advanced: basics, data structures, OOP, files, testing, APIs and projects, with exercises.

18 modules · 45 lessons so far

Module 1 · Beginner

Getting started

What Python is, how to install it, how to run code, your first program, and how to read error messages.

  1. What is Python? Uses, features and examples
  2. Python roadmap for beginners: what to learn
  3. How to install Python and set up VS Code
  4. How to run Python: REPL, scripts and notebooks
  5. Your first Python program, line by line
  6. Python error messages and tracebacks explained

Module 2 · Beginner

Python basics

Variables, numbers, strings, formatted output, user input and readable code: the building blocks of every program.

  1. Python variables and data types, with examples
  2. Python numbers and operators, with examples
  3. Python strings and string methods, with examples
  4. Python f-strings: format output the easy way
  5. Python input() and type conversion explained
  6. Python comments and writing readable code

Module 3 · Beginner

Conditions and loops

Make decisions and repeat work: if statements, loops and pattern matching.

  1. Python if, elif and else, with examples
  2. Python for and while loops, with examples
  3. Python break, continue and pass, with examples
  4. Nested loops and star patterns in Python
  5. Python match statement, with examples
  6. Python loop practice: 20 problems with solutions

Module 4 · Beginner

Lists, dictionaries, sets and tuples

Python's four built-in collections, and how to choose the right one.

  1. Python lists tutorial, with examples
  2. Python dictionary tutorial, with examples
  3. Python tuples and unpacking, with examples
  4. Python sets and set operations, with examples
  5. Python list, dict and set comprehensions
  6. Nested lists, dictionaries and JSON in Python
  7. List, tuple, set or dictionary? How to choose

Module 5 · Beginner

Working with text

Slice, search, clean and format text, and match patterns with regular expressions.

  1. How to clean and split text in Python
  2. Python regular expressions with the re module
  3. Unicode and text encodings in Python
  4. Python string practice: 15 problems

Module 6 · Beginner

Functions and modules

Organise code into reusable functions and modules, and use code other people have written.

  1. Python functions explained, with examples
  2. Python variable scope and the LEGB rule
  3. Recursion in Python, with examples
  4. Python lambda, map, filter and sorted with key
  5. Python type hints for beginners
  6. Python modules and packages explained
  7. pip and virtual environments in Python

Module 7 · Beginner

Files and error handling

Save and load data, and keep programs running when something goes wrong.

  1. Python file handling: read, write, CSV, JSON
  2. Python exceptions: raise and custom exceptions
  3. Python pathlib: work with files and folders
  4. Python logging for beginners

Module 8 · Intermediate

Object-oriented Python

Model real things with classes and objects, the style frameworks like Django are built on.

  1. Python classes and objects for beginners
  2. The __init__ method and instance attributes
  3. Inheritance and super()
  4. Encapsulation, properties and private attributes
  5. Class methods and static methods
  6. Magic (dunder) methods: __str__, __len__ and more
  7. Dataclasses: classes without boilerplate

Module 9 · Intermediate

The standard library

The modules that ship with Python, so you rarely start from scratch.

  1. Dates and times with datetime
  2. collections: Counter, defaultdict and deque
  3. math, random and statistics
  4. os, sys and shutil: talking to your computer
  5. Command-line programs with argparse

Module 10 · Intermediate

Automate the boring stuff

Let Python do repetitive work for you: files, spreadsheets, emails and browsers.

  1. Rename and organise files automatically
  2. Automate Excel with openpyxl
  3. Send emails with Python
  4. Browser automation with Playwright
  5. Schedule Python scripts to run automatically

Module 11 · Intermediate

Testing and debugging

Find bugs faster and prove your code works.

  1. Debugging Python with breakpoints in VS Code
  2. assert and writing your first tests
  3. Testing with pytest
  4. Clean code: PEP 8, linters and formatters

Module 12 · Intermediate

Python and the web

Talk to websites and APIs, and build your own.

  1. How HTTP works: requests and responses
  2. Calling REST APIs with requests
  3. Web scraping with Beautiful Soup
  4. Build your first API with Flask
  5. FastAPI for beginners
  6. Django for beginners: build a blog

Module 13 · Intermediate

Python and databases

Store data properly, with SQL and Python.

  1. SQL basics for Python developers
  2. SQLite with the sqlite3 module
  3. Using an ORM: SQLAlchemy basics
  4. MongoDB with PyMongo

Module 14 · Advanced

Advanced Python

The features that separate beginner code from professional Python.

  1. Python iterators and iterables explained
  2. Python generators and yield, with examples
  3. Python itertools module, with examples
  4. Python functools: partial, reduce, lru_cache
  5. Decorators explained, with examples
  6. Context managers and the with statement
  7. Closures and first-class functions
  8. Mutability, references and copying objects

Module 15 · Advanced

Concurrency and performance

Do several things at once, and make slow code faster.

  1. The GIL explained
  2. Threads with threading and concurrent.futures
  3. Multiprocessing for CPU-heavy work
  4. asyncio basics: async and await
  5. Profiling and speeding up Python code

Module 16 · Intermediate

Python for data

The libraries behind data analysis and machine learning.

  1. NumPy array tutorial for beginners
  2. Pandas DataFrame tutorial for beginners
  3. Charts with Matplotlib
  4. Machine learning for beginners, with Python

Module 17 · Intermediate

Projects

Build real programs that pull everything together, and put them on GitHub.

  1. Number guessing game
  2. To-do list app for the command line
  3. Contact book that saves to JSON
  4. Expense tracker with CSV reports
  5. Weather app using a public API
  6. Quiz game with classes
  7. Web scraper that saves results to a spreadsheet
  8. Put your projects on GitHub: a portfolio guide

Module 18 · Advanced

Python interview preparation

Get ready for Python questions and coding rounds.

  1. 50 Python interview questions with answers
  2. Python coding problems for interviews
  3. Big-O notation in Python, with examples
  4. Python output-prediction questions

Want to learn this with others?

Join our free Python training, run by the theprogrammers community.