Think Python, 2nd edition

by Allen B. Downey

The third edition is coming soon!

You can buy the second edition at Amazon.com

Download Think Python 2e in PDF.

Read Think Python 2e in HTML.

Example programs and solutions to some exercises are in this GitHub repository. Instructions for working with this code are in the preface.

Translations

Here is a Spanish translation by Jorge Espinoza.

Here is a Chinese translation (traditional and simplified) by Du Wenbin.

Here is a Vietnamese translation by Tan H. Nguyen.

Here is a Marathi translation by Sagar Kale.

Peter Hall compiled the glossaries into two documents: glossary by chapter and glossary in alphabetical order.

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 second edition?

  • We’ve upgraded to Python 3: All examples in the book are now Python 3, and the supporting code has been updated to run in both Python 2 and 3.
  • We’ve removed the roadblocks: Based on reader feedback, we know where people had problems, so we’ve fixed or removed the pain points.
  • Python in the browser: For beginners, one of the challenges of getting started is installing Python. For readers who don’t want to install Python right away, we provide instructions for running Python in a browser using PythonAnywhere, a free online programming environment.
  • More Python goodies: We’ve added a chapter to cover some powerful Python features that didn’t make it into the first edition, including list comprehensions and additional data structures.

Think Python 2e 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.

Earlier Versions

The second edition uses 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.