Python exercises with solutions

138 practice problems from the 40 lessons of the Python Programming course, in lesson order and from easy to hard inside each lesson. Open a problem, write your code and press Submit: the tests run in your browser and nothing is sent to a server.

48 easy problems 50 medium problems 40 hard problems

Your first program

3 problems · Read the lesson

Variables and assignment

4 problems · Read the lesson

Numbers and operators

5 problems · Read the lesson

Input and type conversion

4 problems · Read the lesson

Formatting output

3 problems · Read the lesson

Decisions with if

5 problems · Read the lesson

Repeating with for loops

5 problems · Read the lesson

Repeating with while

3 problems · Read the lesson

Nested loops

3 problems · Read the lesson

Working with strings

3 problems · Read the lesson

Lists

3 problems · Read the lesson

enumerate and zip

3 problems · Read the lesson

Lists of lists

3 problems · Read the lesson

Functions and recursion

6 problems · Read the lesson

More about functions

4 problems · Read the lesson

Functions as values

3 problems · Read the lesson

Using modules

4 problems · Read the lesson

Tuples and sets

3 problems · Read the lesson

Dictionaries

3 problems · Read the lesson

List comprehensions

4 problems · Read the lesson

Processing text data

3 problems · Read the lesson

Generators

3 problems · Read the lesson

Errors and exceptions

3 problems · Read the lesson

Raising your own errors

3 problems · Read the lesson

Testing your code

3 problems · Read the lesson

Debugging

3 problems · Read the lesson

Classes and objects

4 problems · Read the lesson

Inheritance

3 problems · Read the lesson

Special methods

3 problems · Read the lesson

Recursion in practice

3 problems · Read the lesson

Memoization

3 problems · Read the lesson

Stacks and queues

4 problems · Read the lesson

Linked lists

3 problems · Read the lesson

Binary trees

3 problems · Read the lesson

How fast is your code?

4 problems · Read the lesson

Sorting algorithms

4 problems · Read the lesson

Two pointers and sliding windows

3 problems · Read the lesson

Project: a grade book

3 problems · Read the lesson

Project: a shop inventory

3 problems · Read the lesson

What comes next

3 problems · Read the lesson