Most programs that we use on a daily basis behave differently depending on what happens during their execution. For example, when a word processor asks us whether we want to save our work, it makes a decision based on our response: saving our work if we answer “yes” and not saving our work if we answer “no.” In this chapter, we’ll learn about if statements, which let our programs make decisions.

We’ll solve two problems: determining the result of a basketball game and determining whether a phone number belongs to a telemarketer.

Problem #3: Winning Team

In this problem, we’ll need to output a message that depends on the outcome ...

Get Learn to Code by Solving Problems now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.