{ "cells": [ { "cell_type": "markdown", "id": "d9724920", "metadata": {}, "source": [ "# Preface\n", "\n", "*(adapted from Allen Downey's* **Think Python**, *Third Edition - see details at bottom)*" ] }, { "cell_type": "markdown", "id": "b76f38c6", "metadata": {}, "source": [ "## Who Is This Book For?\n", "\n", "If you want to learn to program, you have come to the right place.\n", "Python is one of the best programming languages for beginners -- and it is also one of the most in-demand skills.\n", "\n", "You have also come at the right time, because learning to program now is probably easier than ever.\n", "\n", "This book is primarily for people who have never programmed before and people who have some experience in another programming language.\n", "If you have substantial experience in Python, you might find the first few chapters a bit slow. They're still foundational.\n", "\n", "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.\n", "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.\n", "If you have done some programming, but you have not also learned this second language, I hope you find this book helpful." ] }, { "cell_type": "markdown", "id": "b4dd57bc", "metadata": {}, "source": [ "## Goals of the Book\n", "\n", "Writing this book, I tried to be careful with the vocabulary.\n", "I define each term when it first appears.\n", "And there is a glossary at the end of each chapter that reviews the terms that were introduced.\n", "\n", "I also tried to be concise.\n", "The less mental effort it takes to read the book, the more capacity you will have for programming.\n", "\n", "But you can't learn to program just by reading a book -- you have to practice.\n", "For that reason, this book includes exercises at the end of every chapter where you can practice what you have learned.\n", "\n", "If you read carefully and work on exercises consistently, you will make progress.\n", "But I'll warn you now -- learning to program is not easy, and even for experienced programmers it can be frustrating.\n", "As we go, I will suggest strategies to help you write correct programs and fix incorrect ones." ] }, { "cell_type": "markdown", "id": "6516d914", "metadata": {}, "source": [ "## Navigating the Book\n", "\n", "Each chapter in this book builds on the previous ones, so you should read them in order and take time to work on the exercises before you move on.\n", "\n", "The first six chapters introduce basic elements like arithmetic, conditionals, and loops.\n", "They also introduce the most important concept in programming, functions, and a powerful way to use them, recursion.\n", "\n", "Chapters 7 and 8 introduce strings -- which can represent letter, words, and sentences -- and algorithms for working with them.\n", "\n", "Chapters 9 through 12 introduce Python's core data structures -- lists, dictionaries, and tuples -- which are powerful tools for writing efficient programs.\n", "Chapter 12 presents algorithms for analyzing text and randomly generating new text.\n", "Algorithms like these are at the core of large language models (LLMs), so this chapter will give you an idea of how tools like ChatGPT work.\n", "\n", "Chapter 13 is about ways to store data in long-term storage -- files and databases.\n", "As an exercise, you can write a program that searches a file system and finds duplicate files.\n", "\n", "Chapters 14 through 17 introduce object-oriented programming (OOP), which is a way to organize programs and the data they work with.\n", "Many Python libraries are written in object-oriented style, so these chapters will help you understand their design -- and define your own objects.\n", "\n", "The goal of this book is not to cover the entire Python language.\n", "Rather, I focus on a subset of the language that provides the greatest capability with the fewest concepts.\n", "Nevertheless, Python has a lot of features you can use to solve common problems efficiently.\n", "Chapter 18 presents some of these features.\n", "\n", "Finally, Chapter 19 presents my parting thoughts and suggestions for continuing your programming journey." ] }, { "cell_type": "markdown", "id": "a6c15538", "metadata": {}, "source": [ "\n", "## Working in Python Modifications\n", "\n", "This content builds on the excllent book Think Python, 3rd edition by Allen B. Downey.\n", "\n", "The following things have been changed:\n", "* 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.\n", "* 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.\n", "* 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.\n", "* Alignment with standards has been completed. This helps a teacher understand where supplemental content is required.\n", "" ] }, { "cell_type": "markdown", "id": "bfb779bb", "metadata": {}, "source": [ "## Getting started\n", "\n", "For most programming languages, including Python, there are many tools you can use to write and run programs. \n", "These tools are called integrated development environments (IDEs).\n", "In general, there are two kinds of IDEs:\n", "\n", "* Some work with files that contain code, so they provide tools for editing and running these files.\n", "\n", "* Others work primarily with notebooks, which are documents that contain text and code.\n", "\n", "For beginners, I recommend starting with a notebook development environment like Jupyter.\n", "\n", "The notebooks for this book are available from an online repository at (or, for the upstream book, Think Python, at )." ] }, { "cell_type": "markdown", "id": "2ebd2412", "metadata": {}, "source": [ "## Resources for Teachers\n", "\n", "If you are teaching with this book, here are some resources you might find useful.\n", "\n", "* You can find notebooks with solutions to the exercises at , along with links to the additional resources below.\n", "\n", "* Quizzes for each chapter, and a summative quiz for the whole book, are available on request.\n", "\n", "* *Teaching and Learning with Jupyter* is an online book with suggestions for using Jupyter effectively in the classroom. You can read the book at \n", "\n", "* 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 " ] }, { "cell_type": "markdown", "id": "28e7de55", "metadata": {}, "source": [ "## Acknowledgments\n", "\n", "Many thanks to Jeff Elkner, who translated my Java book into Python,\n", "which got this project started and introduced me to what has turned out\n", "to be my favorite language.\n", "Thanks also to Chris Meyers, who contributed several sections to *How to Think Like a Computer Scientist*.\n", "\n", "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.\n", "\n", "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.\n", "\n", "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*.\n", "\n", "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!).\n", "I am also grateful to Luciano for developing the turtle graphics module I use in several chapters, called `jupyturtle`.\n", "\n", "Thanks to all the students who worked with earlier versions of this book and all the contributors who sent in corrections and suggestions.\n", "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.\n", "\n", "If you have a suggestion or correction, please send email to `feedback@thinkpython.com`.\n", "If you include at least part of the sentence the error appears in, that\n", "makes it easy for me to search. Page and section numbers are fine, too,\n", "but not quite as easy to work with. Thanks!" ] }, { "cell_type": "code", "execution_count": null, "id": "4e31cebe", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "a7f4edf8", "metadata": { "tags": [] }, "source": [ "\n", "---\n", "\n", "**Working in Python** — modified by Eric Brown for a high school Computer Science Principles class. Source and modifications: [github.com/porttack/working-in-python](https://github.com/porttack/working-in-python)\n", "\n", "---\n", "\n", "\n", "[Think Python: 3rd Edition](https://allendowney.github.io/ThinkPython/index.html)\n", "\n", "Copyright 2024 [Allen B. Downey](https://allendowney.com)\n", "\n", "Code license: [MIT License](https://mit-license.org/)\n", "\n", "Text license: [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.11" } }, "nbformat": 4, "nbformat_minor": 5 }