Table of Contents » Chapter 3 : Processing : Decisions : Decision Concepts
Decision Concepts
Decisions in programming allow us to change the behavior of our programs based on one or more conditions. In English we might express the need for a decision using a question, like these:
Is today Saturday?
Do I have enough money to pay my rent?
The answers to these questions are boolean, that is, True or False (Yes or No). When we know the answer to these questions, we can react accordingly. We express this using a language construct called if this then that. In programming we also call this a conditional construction. Written in English, the following are examples of conditional constructions that we could use with the two questions above:
If today is Saturday, then go grocery shopping.
If I have enough money, then pay the rent.
These are decisions based on the conditional constructions. The first one, for instance, answers the question is the current day Saturday?. If the answer to that question is yes (True), then we will perform an action, in this example, go grocery shopping. In Python, we have several approaches available to us to create conditional constructions in our code. When we use these approaches our programs can behave differently based on the results of those conditions. This chapter outlines the primary approaches to handle decisions in Python.
In programming, decisions determine the flow of execution of a program based on the evaluation of conditional constructions. Decision-making in Python, as in any programming language, is about choosing which path a program should take. Figure 1 depicts the general form of a condition in programming. When the program execution path reaches a decision, it evaluates one or more conditions that make up the conditional construction. If the result of that evaluation is True (yes), then a code block executes. Once that conditional code block finishes, then the program execution path continues past the conditional construction. If the result of that evaluation is False (or no), then that code block is skipped, and program execution continues without executing the statements in that code block.
Decisions allow programs to respond differently to inputs or situations, making it dynamic and flexible. The ability to make decisions is crucial because, without it, a program would execute the same set of instructions in the same order every time it runs, regardless of different inputs or changing external conditions. Decision-making enables programs to interact meaningfully with data and the environment.

Figure 1: General form of a condition in programming.
Example
Imagine you are writing a program to manage daily tasks. The decision-making part of the program would decide when to attend to different tasks depending on the day of the week. In this example, your program would evaluate conditional constructs like if today is Monday, then do Task A. Figure 2 depicts this scenario.
As you explore decision-making in Python, you will learn how to instruct your program to decide between True or False, and how to handle multiple conditions and scenarios. These features are based on Python's decision structures. Each of these structures serves a specific purpose and is used in different scenarios to guide the flow of your program. We will explore each of these in this chapter.

Figure 2: Example of a condition in programming.