You want to create a simple calculator program in Python that performs basic arithmetic operations like addition, subtraction, multiplication, and division. Which programming construct is commonly used to implement the decision-making logic for each operation in this calculator program?
A) Loops
B) Functions
C) if-else statements
D) Lists
Answer:
C) if-else statements
Explanation:
In a simple calculator program in Python, you typically use if-else statements to determine which arithmetic operation to perform based on the user’s input. Depending on the operator (+, -, *, /) entered by the user, the program decides which mathematical operation to execute using if-else conditions.