APICS Certified Supply Chain Professional (CSCP) — Question 190
A data engineer only wants to execute the final block of a Python program if the Python variable day_of_week is equal to 1 and the Python variable review_period is True.
Which of the following control flow statements should the data engineer use to begin this conditionally executed code block?
Answer options
- A. if day_of_week = 1 and review_period:
- B. if day_of_week = 1 and review_period = "True":
- C. if day_of_week == 1 and review_period == "True":
- D. if day_of_week == 1 and review_period:
- E. if day_of_week = 1 & review_period: = "True":
Correct answer: D
Explanation
The correct answer is D because it properly checks if day_of_week is equal to 1 using '==' and confirms that review_period is True without any string comparison. Option A is incorrect due to the use of a single '=' instead of '==', while options B and C incorrectly compare review_period to a string instead of a boolean. Option E also incorrectly uses a single '=' and contains syntax errors.