Challenges & Extensions

This is an expanded set of exercises and challenges that go beyond what’s asked of readers in the book. Many of these challenges are good starting points for deeper investigations, and can be expanded into full projects. You can do each of these challenges using what’s been presented in the book to that point; if you need something else to complete the challenge, that information is presented in the challenge itself.

I may write some articles about how some of these challenges could be implemented, but I have no intention of developing an overall solution set. The point of these challenges is to push yourself to develop a working solution, and then share it with others for feedback.

For many interesting challenges, a fully-specified problem description would be really long. You may need to make decisions about how to interpret some of these challenges as you work on implementing them. For example, if you’re asked to write a function that deals a hand from a deck of cards, you may have to decide whether to remove the cards from the deck, or just return the hand.

Before trying any of the more complex challenges, consider working through Appendix D, Using Git for Version Control. Using a version control system is critical when working on projects where you could easily make a mistake at some point, but won’t want to start over from scratch.

If you have suggestions or feedback on any of these, please feel free to get in touch. Good luck, and have fun!


Challenge Sets

Each of these sets is made up of a series of smaller challenges. You don’t have to do all of the challenges in a set. Each set is organized by chapter, so you’ll know which challenges you’re ready to try based on how far you’ve gotten in the book. You should finish a chapter before trying the challenges associated with that chapter.

  • Playing Cards

    Model a deck of playing cards in a variety of ways, and build a series of increasingly sophisticated card games. If you’re curious about data analysis work, you can have your computer play itself many times, and analze the results. If you’re interested in web apps, you can make an online version of the game.

    You can start on this challenge as early as Chapter 3.

  • Photo Filters

    Learn about image manipulation, and build your own set of photo filters. If you like data analysis, you can make visualizations of the pixel data in an image. If you’re interested in web apps, make your photo filters available online.

    You can start on this challenge as early as Chapter 3.

  • Automated Alien Invasion Player

    Learn how to write a program that plays Alien Invasion automatically. It’s really interesting to see how the class-based structure of the Alien Invasion project lends itself to automated gameplay. You’ll start out implementing a simple, naive strategy that shoots at aliens rather blindly. Then you’ll learn a number of approaches that will help you develop more interesting and effective strategies.

    You can start on this challenge after you have completed Chapter 14.

  • Coding for Social Justice

    You don’t have to wait until you’ve learned how to program in order to start focusing on serious topics. This set of challenges focuses on issues related to the Black Lives Matter movement. The current challenges focus on the issue of police violence specifically, but I intend to expand the challenges to cover a wider range of issues such as inequity in the criminal justice system, education, housing, health care, and other relevant issues.

    You can start on these challenges as early as Chapter 2.