Python Crash Course, 3rd Edition

A Hands-On, Project-Based Introduction to Programming

Look inside
Python Crash Course is the world’s bestselling programming book, with over 1,500,000 copies sold to date!

Python Crash Course is the world’s best-selling guide to the Python programming language. This fast-paced, thorough introduction will have you writing programs, solving problems, and developing functioning applications in no time.

You’ll start by learning basic programming concepts, such as variables, lists, classes, and loops, and practice writing clean code with exercises for each topic. You’ll also learn how to make your programs interactive and test your code safely before adding it to a project. You’ll put your new knowledge into practice by creating a Space Invaders–inspired arcade game, building a set of data visualizations with Python’s handy libraries, and deploying a simple application online.

As you work through the book, you’ll learn how to:
  • Use powerful Python libraries and tools, including pytest, Pygame, Matplotlib, Plotly, and Django
  • Make increasingly complex 2D games that respond to keypresses and mouse clicks
  • Generate interactive data visualizations using a variety of datasets
  • Build apps that allow users to create accounts and manage their own data, and deploy your apps online 
  • Troubleshoot coding errors and solve common programming problems

New to this edition: This third edition is completely revised to reflect the latest in Python code. New and updated coverage includes VS Code for text editing, the pathlib module for file handling, pytest for testing your code, as well as the latest features of Matplotlib, Plotly, and Django.

If you’ve been thinking about digging into programming, Python Crash Course will provide you with the skills to write real programs fast. Why wait any longer? Start your engines and code!

Covers Python 3.x
Eric Matthes was a high school science, math, and programming teacher, now full-time author, living in Alaska. He has been writing programs since he was five years old and is the author of the Python Flash Cards, also from No Starch Press.
Preface to the Third Edition
Acknowledgments
Introduction
Part I: BASICS
Chapter 1: Getting Started
Chapter 2: Variables and Simple Data Types
Chapter 3: Introducing Lists
Chapter 4: Working with Lists
Chapter 5: if Statements
Chapter 6: Dictionaries
Chapter 7: User Input and while Loops
Chapter 8: Functions
Chapter 9: Classes
Chapter 10: Files and Exceptions
Chapter 11: Testing Your Code
Part II: PROJECTS
Chapter 12: A Ship That Fires Bullets
Chapter 13: Aliens!
Chapter 14: Scoring
Chapter 15: Generating Data
Chapter 16: Downloading Data
Chapter 17: Working with APIs
Chapter 18: Getting Started with Django
Chapter 19: User Accounts
Chapter 20: Styling and Deploying an App
Afterword
Appendix A: Installation and Troubleshooting
Appendix B: Text Editors and IDEs
Appendix C: Getting Help
Appendix D: Using Git for Version Control
Appendix E: Troubleshooting Deployments
Index
"Learning python is a smart investment of your time because the language is efficient and powerful. This book will get you where you need to be to program like a pro." 
—Sandra Henry-Stocker, NetworkWorld

"Eric Matthes's Python Crash Course, 3rd Edition takes a well-regarded text for getting started with Python and brings it up to date for 2023. The book not only covers Python's basics but lets you put them to use in a series of projects involving data analysis, web development, and gaming. Many books offer either Python basics or projects to learn from. This one delivers both."
—Serdar Yegulalp, InfoWorld

"Just looking at the fact that this is the 3rd Edition of Eric's book, you likely realize that there is something special about this . . . It's amazing that he gets all of [this] into 500+ pages and at the same time it's all understandable. . . . ★★★★★"
—Greg Walters, Full Circle Magazine

Reviews for the 2nd Edition:

"With a patient and experienced pedagogical style, and a combination of thorough language instruction and plenty of illustrative sample code, Python Crash Course is a terrific way to begin learning computer programming in general and the Python language in particular."
—Michael J. Ross, web developer and former Slashdot contributor

“It has been interesting to see, over the last few years, No Starch Press, which produces this book, growing and producing future classics that should be alongside the more traditional O’Reilly Press programming books. Python Crash Course is one of those books.”
—Greg Laden, ScienceBlogs

“All of these projects are well thought out and presented in such a way that learning the subject matter and implementing it is much more an enjoyable pastime rather than an onerous task that must be completed. Eric took the time to deal with some rather complex projects and lay them out in a consistent, logical and pleasant manner that draws the reader into the subject willingly, which unfortunately, many authors fail to do.”
Full Circle Magazine

“The book is well presented with good explanations of the code snippets. It works with you, one small step at a time, building more complex code, explaining what's going on all the way.”
—FlickThrough Reviews

“Learning Python with Python Crash Course was an extremely positive experience! A great choice if you’re new to Python.”
—Mikke Goes Coding

"While Python Crash Course uses Python to teach you to code, it also teaches clean programming skills that apply to most other languages."
—Great Lakes Geek

"It does what it says on the tin, and it does it really well. If you want a crash course in Python, fear not!!! The Python Crash Course is an excellent book that provides a thorough introduction to Python that will have you writing programs and solving problems in no time!"
—Technical YA, Best Books to Learn Python Language in 2021
Interior Spread
Interior Spread
Interior Spread

About

Python Crash Course is the world’s bestselling programming book, with over 1,500,000 copies sold to date!

Python Crash Course is the world’s best-selling guide to the Python programming language. This fast-paced, thorough introduction will have you writing programs, solving problems, and developing functioning applications in no time.

You’ll start by learning basic programming concepts, such as variables, lists, classes, and loops, and practice writing clean code with exercises for each topic. You’ll also learn how to make your programs interactive and test your code safely before adding it to a project. You’ll put your new knowledge into practice by creating a Space Invaders–inspired arcade game, building a set of data visualizations with Python’s handy libraries, and deploying a simple application online.

As you work through the book, you’ll learn how to:
  • Use powerful Python libraries and tools, including pytest, Pygame, Matplotlib, Plotly, and Django
  • Make increasingly complex 2D games that respond to keypresses and mouse clicks
  • Generate interactive data visualizations using a variety of datasets
  • Build apps that allow users to create accounts and manage their own data, and deploy your apps online 
  • Troubleshoot coding errors and solve common programming problems

New to this edition: This third edition is completely revised to reflect the latest in Python code. New and updated coverage includes VS Code for text editing, the pathlib module for file handling, pytest for testing your code, as well as the latest features of Matplotlib, Plotly, and Django.

If you’ve been thinking about digging into programming, Python Crash Course will provide you with the skills to write real programs fast. Why wait any longer? Start your engines and code!

Covers Python 3.x

Author

Eric Matthes was a high school science, math, and programming teacher, now full-time author, living in Alaska. He has been writing programs since he was five years old and is the author of the Python Flash Cards, also from No Starch Press.

Table of Contents

Preface to the Third Edition
Acknowledgments
Introduction
Part I: BASICS
Chapter 1: Getting Started
Chapter 2: Variables and Simple Data Types
Chapter 3: Introducing Lists
Chapter 4: Working with Lists
Chapter 5: if Statements
Chapter 6: Dictionaries
Chapter 7: User Input and while Loops
Chapter 8: Functions
Chapter 9: Classes
Chapter 10: Files and Exceptions
Chapter 11: Testing Your Code
Part II: PROJECTS
Chapter 12: A Ship That Fires Bullets
Chapter 13: Aliens!
Chapter 14: Scoring
Chapter 15: Generating Data
Chapter 16: Downloading Data
Chapter 17: Working with APIs
Chapter 18: Getting Started with Django
Chapter 19: User Accounts
Chapter 20: Styling and Deploying an App
Afterword
Appendix A: Installation and Troubleshooting
Appendix B: Text Editors and IDEs
Appendix C: Getting Help
Appendix D: Using Git for Version Control
Appendix E: Troubleshooting Deployments
Index

Praise

"Learning python is a smart investment of your time because the language is efficient and powerful. This book will get you where you need to be to program like a pro." 
—Sandra Henry-Stocker, NetworkWorld

"Eric Matthes's Python Crash Course, 3rd Edition takes a well-regarded text for getting started with Python and brings it up to date for 2023. The book not only covers Python's basics but lets you put them to use in a series of projects involving data analysis, web development, and gaming. Many books offer either Python basics or projects to learn from. This one delivers both."
—Serdar Yegulalp, InfoWorld

"Just looking at the fact that this is the 3rd Edition of Eric's book, you likely realize that there is something special about this . . . It's amazing that he gets all of [this] into 500+ pages and at the same time it's all understandable. . . . ★★★★★"
—Greg Walters, Full Circle Magazine

Reviews for the 2nd Edition:

"With a patient and experienced pedagogical style, and a combination of thorough language instruction and plenty of illustrative sample code, Python Crash Course is a terrific way to begin learning computer programming in general and the Python language in particular."
—Michael J. Ross, web developer and former Slashdot contributor

“It has been interesting to see, over the last few years, No Starch Press, which produces this book, growing and producing future classics that should be alongside the more traditional O’Reilly Press programming books. Python Crash Course is one of those books.”
—Greg Laden, ScienceBlogs

“All of these projects are well thought out and presented in such a way that learning the subject matter and implementing it is much more an enjoyable pastime rather than an onerous task that must be completed. Eric took the time to deal with some rather complex projects and lay them out in a consistent, logical and pleasant manner that draws the reader into the subject willingly, which unfortunately, many authors fail to do.”
Full Circle Magazine

“The book is well presented with good explanations of the code snippets. It works with you, one small step at a time, building more complex code, explaining what's going on all the way.”
—FlickThrough Reviews

“Learning Python with Python Crash Course was an extremely positive experience! A great choice if you’re new to Python.”
—Mikke Goes Coding

"While Python Crash Course uses Python to teach you to code, it also teaches clean programming skills that apply to most other languages."
—Great Lakes Geek

"It does what it says on the tin, and it does it really well. If you want a crash course in Python, fear not!!! The Python Crash Course is an excellent book that provides a thorough introduction to Python that will have you writing programs and solving problems in no time!"
—Technical YA, Best Books to Learn Python Language in 2021

Photos

Interior Spread
Interior Spread
Interior Spread

Books for Native American Heritage Month

In celebration of Native American Heritage Month this November, Penguin Random House Education is highlighting books that detail the history of Native Americans, and stories that explore Native American culture and experiences. Browse our collections here: Native American Creators Native American History & Culture

Read more

2024 Middle and High School Collections

The Penguin Random House Education Middle School and High School Digital Collections feature outstanding fiction and nonfiction from the children’s, adult, DK, and Grupo Editorial divisions, as well as publishers distributed by Penguin Random House. Peruse online or download these valuable resources to discover great books in specific topic areas such as: English Language Arts,

Read more

PRH Education High School Collections

All reading communities should contain protected time for the sake of reading. Independent reading practices emphasize the process of making meaning through reading, not an end product. The school culture (teachers, administration, etc.) should affirm this daily practice time as inherently important instructional time for all readers. (NCTE, 2019)   The Penguin Random House High

Read more

PRH Education Translanguaging Collections

Translanguaging is a communicative practice of bilinguals and multilinguals, that is, it is a practice whereby bilinguals and multilinguals use their entire linguistic repertoire to communicate and make meaning (García, 2009; García, Ibarra Johnson, & Seltzer, 2017)   It is through that lens that we have partnered with teacher educators and bilingual education experts, Drs.

Read more

An Interview with Python Crash Course Author Eric Matthes

This Author Spotlight is on Python programmer/educator extraordinaire Eric Matthes, author of the international bestseller (now in its third edition) Python Crash Course  from No Starch Press. In the following Q&A, we discuss how reader feedback shaped the latest edition of his book, why he chose teaching over a career in physics, the importance of

Read more