
Ultimate access to all questions.
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?
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":
Explanation:
Correct Answer: D
Explanation:
if day_of_week == 1 and review_period:=) which is assignment, not comparisonreview_period to the string "True" instead of the boolean value True&) instead of the logical AND keyword (and), and also incorrectly compares to the string "True"Key Python Concepts:
== for equality comparison, not = (which is for assignment)and for logical AND operations, not & (which is bitwise AND)True and False (without quotes), not strings "True" or "False"if review_period:)Note: Since both A and D are identical and correct, but the provided answer indicates D, we follow the given answer. In practice, both A and D would be correct answers.