Skip to Main Content
Learn to Code by Solving Problems
book

Learn to Code by Solving Problems

by Daniel Zingaro
June 2021
Beginner content levelBeginner
336 pages
7h 11m
English
No Starch Press
Content preview from Learn to Code by Solving Problems

6DESIGNING PROGRAMS WITH FUNCTIONS

image

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

40 Algorithms Every Programmer Should Know

40 Algorithms Every Programmer Should Know

Imran Ahmad
Coding with AI: The End of Software Development as We Know It

Coding with AI: The End of Software Development as We Know It

Tim O'Reilly, Addy Osmani, Gergely Orosz, Kent Beck, Camille Fournier, Avi Flombaum, Maxi Ferreira, Harper Reed, Jay Parikh, Birgitta Böckeler, Angie Jones, Craig McLuckie, Patty O’Callaghan, Chip Huyen, swyx, Andrew Stellman, Phillip Carter, Nikola Balic, Brett Smith, Chelsea Troy, Lili Jiang

Publisher Resources

ISBN: 9781098129033