6DESIGNING PROGRAMS WITH FUNCTIONS
When writing large programs, it’s important to organize our code into smaller logical pieces, each of which contributes to the overall goal. That way, we’ll be able to think about each piece on its own, without worrying about what other pieces are doing. Then we’ll put the pieces together. These pieces are called functions.
In this chapter, we’ll use functions to break down and solve two problems: calculating the score in a two-player card game and determining whether boxes of action figures can be nicely organized.
Problem #14: Card Game
In this problem, we’ll implement a two-player card game. As part of thinking ...
Get Learn to Code by Solving Problems now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.