nerdexam
Databricks

DATABRICKS-CERTIFIED-DATA-ENGINEER-ASSOCIATE · Question #3

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…

The correct answer is D. if day_of_week == 1 and review_period. Python uses '==' for equality comparison, not '=' (which is assignment). Additionally, the variable 'review_period' is already a Boolean (True/False), so it can be used directly in the condition without comparing it to the string 'True'. Answer D ('if day_of_week == 1 and…

Submitted by takeshi77· Apr 18, 2026ELT with Spark SQL and Python

Question

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?

Options

  • Aif day_of_week = 1 and review_period:
  • Bif day_of_week = 1 and review_period = "True":
  • Cif day_of_week == 1 and review_period == "True":
  • Dif day_of_week == 1 and review_period:
  • Eif day_of_week = 1 & review_period: = "True":

How the community answered

(48 responses)
  • A
    2% (1)
  • C
    6% (3)
  • D
    88% (42)
  • E
    4% (2)

Explanation

Python uses '==' for equality comparison, not '=' (which is assignment). Additionally, the variable 'review_period' is already a Boolean (True/False), so it can be used directly in the condition without comparing it to the string 'True'. Answer D ('if day_of_week == 1 and review_period:') is correct because it uses '==' to compare the integer, and leverages the boolean truthiness of 'review_period' directly. Comparing a boolean to the string 'True' (as in option C) would evaluate as False because True != 'True' in Python.

Topics

#Python syntax#Control flow#Conditional statements#Logical operators

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-DATA-ENGINEER-ASSOCIATE Practice