← Learn
Learn · Python

Python intermediate

Eleven lessons on the tools of real programs: dictionaries, tuples and sets, string methods and formatting, comprehensions with enumerate and zip, more on functions, exceptions and tracebacks, files with CSV and JSON, modules and the standard library, classes, and testing and debugging.

Part of the Python developer path.

Take first: Python basics.

  1. Before you start

    A quick recap of the basics this course builds on: variables, types, if, loops, lists and functions.

    5 questions
  2. Dictionaries

    Looking things up by name instead of position: keys and values, adding and changing, get(), and looping over a dict.

    6 questions
  3. Tuples and sets

    Fixed groups of values with tuples, unpacking, and sets for unique items and fast membership tests.

    6 questions
  4. Strings in depth

    Splitting and joining, trimming, searching and checking strings, plus formatting numbers inside f-strings.

    7 questions
  5. Comprehensions, enumerate and zip

    Building lists and dicts in one line, numbering items as you loop with enumerate(), and pairing lists with zip().

    7 questions
  6. More about functions

    Default values, keyword arguments, *args and **kwargs, scope, docstrings, and the mutable default trap.

    6 questions
  7. Errors and exceptions

    Reading a traceback, catching errors with try and except, else and finally, and raising your own.

    6 questions
  8. Reading and writing files

    Opening files with with, reading line by line, writing, paths, and the csv and json modules for data files.

    7 questions
  9. Modules and the standard library

    Importing code, the most useful built-in modules (math, random, datetime, collections), and installing packages with pip.

    6 questions
  10. Classes and objects

    Making your own types with class: __init__ and self, attributes, methods, and __str__ for printing.

    6 questions
  11. Testing and debugging

    Finding bugs on purpose: assert, writing small tests, pytest, print debugging, the debugger, and common bugs.

    6 questions
More info

How it works

Each lesson is a short read with examples, then a few practice questions. Some ask you to type an answer (a number, an address, what a piece of code prints), some have you pick one, and some have you tap steps or lines into the right order. You can try again as often as you like; after two misses there’s a button to show the answer.

What do I need to know first?

Python basics, or the same ground elsewhere: variables, if, loops, lists and functions. The first lesson recaps all of it.

Related courses

Where is my progress saved? In this browser, like the rest of the site. Nothing to sign up for.

“Python” is a registered trademark of the Python Software Foundation. This course isn’t made by or affiliated with it.