Python Crash Course Book Review
Dylan | Jul 20, 2020
I’m excited to finally review “Python Crash Course: A Hands-On, Project-Based Introduction to Programming” by Eric Matthes published by No Starch Press. Matthes teaches math and science at a small school in Alaska. At work, he regularly finds himself breaking down abstract concepts into easy-to-understand bites, making him a prime candidate to write an introductory programming book.
One day in class a student asked him what a programmer needed to know to start working on important projects. To answer his question and help all future students, he made a list of the necessary things and hung it on the wall in his classroom.
Fast forward and Matthes found himself discussing a book writing opportunity after giving a presentation at PyCon 2013. Matthes would use the list hanging in his classroom to write his book proposal.
With this said, I believe the intent of the book hit its mark. Python Crash Course certainly covers what you need to know to start working on important projects. Its goal is to bring you up to speed with Python as quickly as possible, written with the absolute beginner in mind.
Beyond teaching the fundamentals of Python, this book also aims to teach good programming habits and help readers build a solid foundation in general programming concepts.
OverviewThe book is cleverly split into two parts. The first part spends eleven chapters covering the basics of Python and programming concepts, while the second part dives head-first into three large projects.
Part IPart one has eleven chapters dedicated to the following topics:
- Getting Started
- Variables and Simple Data Types
- if Statements
- User Input and while Loops
- Files and Exceptions
- Testing Your Code
Let’s quickly run through the primary topics covered in part one.
Chapter one starts exactly where any Python learning resource should, how to install Python, and set up a programming environment. For beginners, this can be quite a difficult task and it’s a shame for them to give up before ever writing a line of code. Matthes guides us through the process on Linux, Mac, and Windows. After building our environment, we’re ready to learn!
Chapter two introduces variables and basic data types such as strings, integers, and floats. We learn how to name and use variables as well as how to avoid common type errors. At the end of the chapter, Matthes touches on how to write comments and their importance.
Chapter three presents a fundamental part of programming, lists. Matthes shares how to access, modify, add, and remove items in a list. Furthermore, we learn how to find the length of a list, sort a list, and even reverse its order.
Chapter four introduces for loops, an important tool for working with lists, while also touching on more advanced features of lists. As always, he guides us through avoiding common errors and handling them when they arise. At the end of this chapter, Matthes also introduces PEP 8 and general styling guidelines.
Chapter five jumps into writing conditional tests and if statements. Often in programming, we want our code to do different things depending on the condition of something. In this chapter, we learn how to choose the correct process for any given case using if-elif-else statements.
Chapter six moves into dictionaries, a powerful Python data type. Matthes shows us how to access, add, modify, and remove dictionary keys and values. He also ends the chapter by introducing nesting, how to put lists inside of lists.
Chapter seven hits on prompting the user for input and writing while loops. Building on the introduction to for loops in chapter four, we learn how to use a flag to break out of a while loop, as well as how the keywords break, pass, and continue work.
Chapter eight presents functions and how to pass values to them and return values from them. Functions are important tools for keeping your code DRY (Don’t repeat yourself). This chapter will also enable you to break complicated logic down into smaller maintainable parts. In the conclusion of this chapter, Matthes shows how to store functions in modules and access them from different python files.
Chapter nine empowers us to start incorporating the power of OOP (object-oriented programming) into our projects through the use of classes. We learn how to write a class and make instances of it. Matthes also breaks down the often-complicated topic of class inheritance in an approachable way before concluding the chapter by explaining more about importing from other modules.
Chapter ten moves into an exciting part of programming, working with files. In this chapter, we learn how to read, write, and edit .txt files with Python. This allows us to store some information permanently and later retrieve it. Matthes also touches on exceptions and how to handle them.
Chapter eleven wraps up part one with a topic often overlooked by beginners, testing code. We learn how to test our functions and classes with unit tests and test cases. Testing ensures that changes to our code do not cause our functions and classes to behave in undesirable ways.
An important additional note: each chapter has practice problems to help solidify the concepts you’re learning. Completing at least a few of the practice problems throughout the chapters is an important step to ensure you truly understand how these things work with a real Python interpreter. Plus, as we’ll see in chapter two, the best way to learn is by doing!
Part IIPart two gets completely hands on with three awesome projects in completely different Python domains. In part two, you’ll build:
- Alien Invasion Game
- Data Visualization
- Web Application
In part two, we continue learning new important concepts while simultaneously reinforcing those basic concepts and tools from part one. Let’s take a closer look at each of the three projects.
In the first project, Matthes helps us build an Alien Invasion game using the popular game library, Pygame. By the end of this project, we’ll be able to effectively move objects around on the screen and accept user keyboard and mouse input in real-time to change the state of our game. Throughout this project, we’ll greatly expand our understanding of object-oriented programming while also learning new essential skills such as refactoring our code.]
In the second project, Matthes shows us how to handle and visualize data. In its current state, Python is one of the best languages for data processing because of its strong presence in data science and machine learning. This project helps you begin working with the popular library, matplotlib, to visualize data. You also learn how to generate random data yourself. Generating random data is interesting, but to solve real-world problems, we’ll want to work with real-world data. This project also teaches us how to download data, work with CSV files, and JSON. Matthes also helps us learn how to work with APIs.
In the third and final project, Matthes guides us through creating your own Django-powered website! In this project, we learn the importance of creating and using a virtual environment. In addition, we learn how to work with Django admin, models, views, urls, and templates. Using all of these together, we can allow web users to login and logout of our sites, as well as add and remove entries (such as comments or new posts).
My OpinionWriting an introductory programming book isn’t an easy task. It’s not easy for beginners to read about abstract programming concepts and fully understand them. I believe this takes time and lots of tinkering; however, Matthes’ explanations are certainly as good as it gets.
Perhaps due to his background and experience educating children, he’s mastered the art of carefully breaking down complicated ideas. In addition to explanations, Python Crash Course offers many code snippets to help readers understand how the code is being interpreted.
For me, the best part of the book is its hands-on approach. Too many beginners get stuck in a learning trap, where they incorrectly believe they can’t do a project until they perfectly understand everything conceptually. Paradoxically, the only way to fully understand these concepts is through coding and working on projects. Every chapter has practice problems to solve and the second half of the book is entirely dedicated to projects.
This book goes far beyond Python, teaching fundamental programming principles such as object-oriented design, testing, refactoring, and many more. These principles extend beyond programming languages and are important for writing clean code in any language.
My Experience with the BookI bought this book going into winter vacation during my Sophomore year of university. I returned home for four weeks and planned to tear through as much of the book as I could before the start of the spring semester. This was my first attempt to learn programming and worked through it pretty quickly, making sure to do all of the practice problems.
In four weeks, I managed to read all of part one and complete the first two projects in part two. Although I certainly didn’t understand all of the topics covered in the book off the bat, I learned an incredible amount and the Alien Invasion project was instrumental in helping me understand classes.
Perhaps the best part of my experience with this book came when I couldn’t figure out something in the Alien Invasion game. I went over the code in the book several times trying to find any discrepancies between the code in the book and the code on my screen.
After spinning my wheels for a couple of days, I decided to email the author and ask for help. I assumed he probably wouldn’t respond, but at least I would have tried. To my surprise, he promptly replied and guided me in the proper direction to finding the solution. If you’re reading, thanks Eric!
ConclusionThis is the book I always recommend to anyone wanting to learn programming but aren’t sure where to start. Matthes manages to cover a wealth of information and more importantly, present it in an easy-to-understand manner. The design of the two parts is ingenious and helps you quickly learn what you need to know and then later drive it home.
This book would make the perfect gift for anyone interested in computers or computer science. You can purchase a copy of it from Amazon here.
Have you read this book? What did you think about it? Let me know in the comments below!