Think Python

by Allen B. Downey

You can order the third edition from Bookshop.org if you want to support local bookstores or from Amazon if you don’t.

Or read the online version of the book here. If you are enjoying the free version, please consider buying me a coffee.

Supporting code and Jupyter notebooks are in this GitHub repository.

The second edition is here.

Description

Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming; it is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression. Larger pieces, like recursion and object-oriented programming, are divided into a sequence of smaller steps and introduced over the course of several chapters.

What’s new in the third edition?

  • Each chapter of the book is a Jupyter notebook, so you can read the text, run the code, and work on the exercises, all in one place. And the notebooks run on Colab, so you don’t have to install anything to get started.
  • Every chapter includes guidance for using AI tools like ChatGPT to accelerate learning.
  • The new edition covers several new topics, including regular expressions and automated testing with doctest and unittest.
  • And it includes more and better exercises.

Think Python is a Free Book. It is available under the Attribution-NonCommercial-ShareAlike 4.0 International, which means that you are free to copy, distribute, and modify it, as long as you attribute the original work, make your modified version available under a compatible license, and don’t use it for commercial purposes.

If you have comments, corrections or suggestions, please send me email at feedback{at}thinkpython{dot}com.

Translations

A German translation is available here

A Vietnamese translation is available here

Earlier Versions

The second and third editions use Python 3.  If you are using Python 2, you might want to use the first edition, which is here.

A previous edition of this book was published by Cambridge University press with the title Python for Software Design. This edition is available from Amazon.com.

The original Python version of the book was published by Green Tea Press with the title How to Think Like a Computer Scientist: Learning with Python. This edition is available from from Lulu.com.