Think Python, first edition

by Allen B. Downey

The third edition is available now!

This is the first edition of Think Python, which uses Python 2.

You can buy this book at

Download Think Python in PDF.

Read Think Python in HTML.

Example programs and solutions to some problems are here (links to specific examples are in the book).  The code is also available from this GitHub repository.


Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming, and 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.

Some examples and exercises are based on Swampy, a Python package written by the author to demonstrate aspects of software design, and to give readers a chance to experiment with simple graphics and animation.

Think Python is a Free Book. It is available under the Creative Commons Attribution-NonCommercial 3.0 Unported License, which means that you are free to copy, distribute, and modify it, as long as you attribute the work 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.

Other Free Books by Allen Downey are available from Green Tea Press.


Earlier Versions

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

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

Translations and adaptations

Andrea Zanella has translated the book into Italian. The source is in this GitHub repository, or you can download the PDF version.

Sat Kumar Tomer has written a related book, Python in Hydrology availablehere.

Jeff Elkner, who was my co-author on How to Think, is working on a second edition, available here.

The book Apprendre a programmer avec Python by Gerard Swinnen started as a French translation of How to Think…, but has evolved into a substantially different book.

Ricardo Perez has translated How to Think… into Spanish and adapted it for the Eiffel programming language. His translation is available here.