Chapter 4: Problem 2
What is a decision structure?
Short Answer
Expert verified
Answer: A decision structure, also known as a conditional structure or "if" statement, is a control structure that allows a program to execute different code based on a given condition. It usually consists of a condition that evaluates to either true or false, and separate code segments to be executed based on the outcome.
Example in Python:
```python
age = 16
if age >= 18:
print("You are old enough to vote.")
else:
print("You are not old enough to vote.")
```
In this example, the program checks if the `age` variable is greater than or equal to 18. If true, it prints "You are old enough to vote," and if false, it prints "You are not old enough to vote."