Preface#
(adapted from Allen Downey’s Think Python, Third Edition - see details at bottom)
Who Is This Book For?#
If you want to learn to program, you have come to the right place. Python is one of the best programming languages for beginners – and it is also one of the most in-demand skills.
You have also come at the right time, because learning to program now is probably easier than ever.
This book is primarily for people who have never programmed before and people who have some experience in another programming language. If you have substantial experience in Python, you might find the first few chapters a bit slow. They’re still foundational.
One of the challenges of learning to program is that you have to learn two languages: one is the programming language itself; the other is the vocabulary we use to talk about programs. If you learn only the programming language, you are likely to have problems when you need to interpret an error message, read documentation, talk to another person, or use virtual assistants. If you have done some programming, but you have not also learned this second language, I hope you find this book helpful.
Goals of the Book#
Writing this book, I tried to be careful with the vocabulary. I define each term when it first appears. And there is a glossary at the end of each chapter that reviews the terms that were introduced.
I also tried to be concise. The less mental effort it takes to read the book, the more capacity you will have for programming.
But you can’t learn to program just by reading a book – you have to practice. For that reason, this book includes exercises at the end of every chapter where you can practice what you have learned.
If you read carefully and work on exercises consistently, you will make progress. But I’ll warn you now – learning to program is not easy, and even for experienced programmers it can be frustrating. As we go, I will suggest strategies to help you write correct programs and fix incorrect ones.
Working in Python Modifications#
This content builds on the excllent book Think Python, 3rd edition by Allen B. Downey.
The following things have been changed:
Remove recommendations to use AI (virtual assistants). While this can be a good idea for some self motivated individuals, it frequently leads to cognative offloading in a way that reduces retention. And it is a violation of policy in some schools.
JupyterLite containers are the default notebook container. This runs completely in the browser and is quite fast. Google Colab is blocked at my school, but JupyterLite works just fine.
Chapter exercises are available. These differ from the practice exercises in each chapter. I assign these to my high school students and ask them to submit their notebooks.
Alignment with standards has been completed. This helps a teacher understand where supplemental content is required.
Getting started#
For most programming languages, including Python, there are many tools you can use to write and run programs. These tools are called integrated development environments (IDEs). In general, there are two kinds of IDEs:
Some work with files that contain code, so they provide tools for editing and running these files.
Others work primarily with notebooks, which are documents that contain text and code.
For beginners, I recommend starting with a notebook development environment like Jupyter.
The notebooks for this book are available from an online repository at https://python.porttack.com (or, for the upstream book, Think Python, at https://allendowney.github.io/ThinkPython).
Resources for Teachers#
If you are teaching with this book, here are some resources you might find useful.
You can find notebooks with solutions to the exercises at https://allendowney.github.io/ThinkPython, along with links to the additional resources below.
Quizzes for each chapter, and a summative quiz for the whole book, are available on request.
Teaching and Learning with Jupyter is an online book with suggestions for using Jupyter effectively in the classroom. You can read the book at https://jupyter4edu.github.io/jupyter-edu-book
One of the best ways to use notebooks is live coding, where an instructor writes code and students follow along in their own notebooks. To learn about live coding – and get other great advice about teaching programming – I recommend the instructor training provided by The Carpentries, at https://carpentries.github.io/instructor-training
Acknowledgments#
Many thanks to Jeff Elkner, who translated my Java book into Python, which got this project started and introduced me to what has turned out to be my favorite language. Thanks also to Chris Meyers, who contributed several sections to How to Think Like a Computer Scientist.
Thanks to the Free Software Foundation for developing the GNU Free Documentation License, which helped make my collaboration with Jeff and Chris possible, and thanks to the Creative Commons for the license I am using now.
Thanks to the developers and maintainers of the Python language and the libraries I used, including the Turtle graphics module; the tools I used to develop the book, including Jupyter and JupyterBook; and the services I used, including ChatGPT, Copilot, Colab and GitHub.
Thanks to the editors at Lulu who worked on How to Think Like a Computer Scientist and the editors at O’Reilly Media who worked on Think Python.
Special thanks to the technical reviewers for the second edition, Melissa Lewis and Luciano Ramalho, and for the third edition, Sam Lau and Luciano Ramalho (again!).
I am also grateful to Luciano for developing the turtle graphics module I use in several chapters, called jupyturtle.
Thanks to all the students who worked with earlier versions of this book and all the contributors who sent in corrections and suggestions. More than 100 sharp-eyed and thoughtful readers have sent in suggestions and corrections over the past few years. Their contributions, and enthusiasm for this project, have been a huge help.
If you have a suggestion or correction, please send email to feedback@thinkpython.com.
If you include at least part of the sentence the error appears in, that
makes it easy for me to search. Page and section numbers are fine, too,
but not quite as easy to work with. Thanks!
Working in Python — modified by Eric Brown for a high school Computer Science Principles class. Source and modifications: github.com/porttack/working-in-python
Copyright 2024 Allen B. Downey
Code license: MIT License
Text license: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International