Databricks Certified Data Engineer Associate — Question 99

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

Correct answer: D

Explanation

The correct answer is D because it uses the equality operator '==' to compare day_of_week with 1 and checks if review_period is True correctly. Option A incorrectly uses a single '=' for assignment instead of '==', while B mistakenly treats review_period as a string instead of a boolean. Option C has syntax errors with incorrect use of '&' and '='.