Think Python

How to Think Like a Computer Scientist

by Allen B. Downey

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

If you are using Python 3, you might want to use the second edition, which is here.

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).


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 Press with 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 available here.

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.

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

Consider making a donation toward my web hosting bill.


If you would like to make a contribution to support my books, you can use the button below. Thank you!
Pay what you want:

Like this book?

Are you using one of our books in a class?

Please consider filling out this short survey.

Think DSP

Think Java

Think Bayes

Think Python 2e

Think Stats 2e

Think Complexity