2.10 Conditionals
A conditional statement is one that says, “If this is true, do that thing, otherwise do that other thing.” It’s up to us to decide what we mean by “this,” “that thing,” and “that other thing.”
Conditional statements change the flow of execution. Instead of evaluating expression after expression in sequence, conditionals allow us to branch and do different things based on whether some condition is true.
When we evaluate one expression after another with no variation, we perform sequential processing. When a condition can alter the evaluation flow, we do dynamic processing.
2.10.1 “if” and “else”
Let’s look at an example of a vending machine that dispenses cookies. Suppose you press a button requesting a shortbread cookie.
if number_of_shortbread_cookies == 0:
...