Python: From Basics to Expert
Four levels, twelve lessons, every example runs in your browser
Python is a general-purpose language built around being readable. It is the usual first language for people learning to program, and also the usual language for data analysis, machine learning, automation and scientific computing - which is unusual, and worth noticing. Very few languages are both a good first one and a serious professional one.
Overview
This course teaches the language itself rather than any one of those uses, because the language is what they all share. If you are heading for data science, this is the course the rest of that track assumes.
Introduction
This is a first course in Python and assumes no programming at all; if you have written another language, Level 1 will mostly be learning where Python differs. If you already use Python at work, the course earns its place from Level 3 on, where the behaviour you have relied on gets explained rather than demonstrated.
Each level is three lessons and a Level Check quiz, and the course ends with an Expert Exam. Every example runs in the browser at the version this course teaches, with the standard library available - press Try yourself and it opens in the compiler, where you edit on the left and see the output on the right. Nothing is installed and nothing is sent to a server.
Every example runs in the browser, at the version this course teaches, with the standard library available. Nothing is installed and nothing is sent to a server.
By the end you will be able to write Python that other people can maintain: functions whose arguments read well at the call site, the right collection for the job rather than a list every time, classes that behave like built-in types, generators that handle a file larger than memory, and type hints that describe a boundary without cluttering the code behind it.
What you will be able to do
- Explain why assignment never copies, and when that matters
- Choose between a list, a tuple, a dict and a set on purpose
- Write comprehensions that stay readable
- Give a class the dunder methods that make it feel built in
- Handle failure precisely, and guarantee cleanup
- Write a decorator, and a generator, and know when each fits
What each level covers
4 levels · 16 lessons
-
Level 1 - Basic
The foundations, in the order they cause trouble. Names and values first, because the difference between the two explains the mutable default argument and the list that changed by itself; then the flow of control, including the else that belongs to a loop; then functions, and how to write arguments that read well where they are called rather than where they are defined.
4 lessons 39 min of reading
Start with Values, Names and Types → -
Level 2 - Intermediate
The collections you will reach for every day, and the text handling around them. Lists and tuples with slicing and the copy that is not as deep as you think; dictionaries and sets, with lookups that do not raise, the live views, Counter and defaultdict; and strings, f-strings and their format mini-language, and the encodings that cause the rest.
4 lessons 41 min of reading
Start with Lists, Tuples and Slicing → -
Level 3 - Advanced
Where Python stops looking like other languages. Comprehensions and the iterator protocol explain what a for loop actually does; dataclasses and dunder methods let your own types behave like built-in ones, including comparison and printing; and the last lesson covers exceptions and context managers, which is how a program fails without leaving a mess.
4 lessons 46 min of reading
Start with Comprehensions and the Iterator Protocol → -
Level 4 - Expert
The features that make libraries possible. Decorators and closures, built up from what a function actually is; generators and itertools for data too large to hold, with laziness as a design choice rather than an optimisation; and type hints as they are used in modern Python, at the edges, where the cost is lowest and the value is highest.
4 lessons 54 min of reading
Start with Decorators and Closures →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- No prior Python
- Some experience of any programming language helps but is not required
Common questions
- What does the Python: From Basics to Expert course cover?
- It is 4 levels and 16 lessons: Level 1 - Basic; Level 2 - Intermediate; Level 3 - Advanced; Level 4 - Expert. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 180 minutes of reading and exercises - roughly 3 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- No prior Python. Some experience of any programming language helps but is not required.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Explain why assignment never copies, and when that matters. Choose between a list, a tuple, a dict and a set on purpose. Write comprehensions that stay readable. Give a class the dunder methods that make it feel built in. Handle failure precisely, and guarantee cleanup. Write a decorator, and a generator, and know when each fits.