Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Data Engineer Associate All Questions

View all questions & answers for the Certified Data Engineer Associate exam

Exam Certified Data Engineer Associate topic 1 question 22 discussion

Actual exam question from Databricks's Certified Data Engineer Associate
Question #: 22
Topic #: 1
[All Certified Data Engineer Associate 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":
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
4be8126
Highly Voted 1 year, 7 months ago
The correct control flow statement to begin the conditionally executed code block would be D. if day_of_week == 1 and review_period:. This statement will check if the variable day_of_week is equal to 1 and if the variable review_period evaluates to a truthy value. The use of the double equal sign (==) in the comparison of day_of_week is important, as a single equal sign (=) would be used to assign a value to the variable instead of checking its value. The use of a single ampersand (&) instead of the keyword and is not valid syntax in Python. The use of quotes around True in options B and C will result in a string comparison, which will not evaluate to True even if the value of review_period is True.
upvoted 17 times
...
806e7d2
Most Recent 5 days, 16 hours ago
Selected Answer: D
In Python, the control flow statement to check conditions involves the following syntax: == for equality comparison: To compare if day_of_week is equal to 1, we use ==. Boolean evaluation: The variable review_period is already a Boolean (True/False). There's no need to compare it to a string like "True"; instead, it can be directly evaluated in the condition. and for logical conjunction: The and operator ensures both conditions must be true for the block to execute.
upvoted 1 times
...
3fbc31b
4 months, 2 weeks ago
Selected Answer: D
You need the == to use the "equals" operation. A single "=" is an assignment operation.
upvoted 1 times
...
Mircuz
8 months, 3 weeks ago
Selected Answer: D
C fits if you're looking for a string == 'True', in this case you are using a boolean so D
upvoted 2 times
...
SerGrey
10 months, 3 weeks ago
Selected Answer: D
D is correct
upvoted 1 times
...
Garyn
11 months ago
Selected Answer: D
D. if day_of_week == 1 and review_period: - In Python, the equality comparison operator is ==, not =. == is used to check if two values are equal. - The logical operator "and" is used to combine two conditions, ensuring that both conditions (day_of_week == 1 and review_period) are true for the subsequent code block to execute. - day_of_week == 1 checks if the variable day_of_week is equal to the integer value 1. - review_period is already assumed to be a Boolean variable since it is stated to be True (without quotes) in the question. Therefore, it should not be compared to a string "True". Therefore, option D correctly represents the condition for executing the final block of the Python program based on the given conditions.
upvoted 1 times
...
awofalus
1 year ago
Selected Answer: D
D is correct
upvoted 1 times
...
VijayKula
1 year, 1 month ago
Selected Answer: D
review_period == "true" is different from review_period == true
upvoted 1 times
...
vctrhugo
1 year, 2 months ago
Selected Answer: D
D. if day_of_week == 1 and review_period: The correct control flow statement to begin the conditionally executed code block is option D. In Python, the == operator is used for equality comparison, and and is used for logical "and" operations. So, this statement checks if day_of_week is equal to 1 and review_period is True (a boolean value), which is the correct way to express the conditions you mentioned.
upvoted 1 times
...
[Removed]
1 year, 2 months ago
Selected Answer: D
Answer is D
upvoted 1 times
...
Atnafu
1 year, 4 months ago
D if day_of_week == 1 and review_period:
upvoted 1 times
...
prasioso
1 year, 6 months ago
Selected Answer: D
in python value comparison is done by double equal signs (==). in case of boolean values that are TRUE these may be omitted. Quotes around True would result in string comparison and here we are comparing to a bool value.
upvoted 2 times
...
Bob123456
1 year, 6 months ago
Answer is 'D' day_of_week=1 review_period = True 1) if day_of_week == 1 and review_period: print("yes") output: Above code block's output is yes 2) if day_of_week == 1 and review_period == "True": print("yes") output: There is no output for above code block
upvoted 1 times
...
Majjjj
1 year, 6 months ago
Selected Answer: D
The data engineer should use option D: if day_of_week == 1 and review_period:. This statement checks if the variable day_of_week is equal to 1 and if the variable review_period is True. It uses the double equal sign (==) to compare the values of the variables, and does not use quotes around the keyword True, which is a boolean value.
upvoted 1 times
...
surrabhi_4
1 year, 7 months ago
Selected Answer: D
option D
upvoted 2 times
...
XiltroX
1 year, 7 months ago
Selected Answer: C
I believe the right answer is C
upvoted 1 times
lgkofficialwork
1 year, 5 months ago
It's not C. Conditional check of "True" is treated as a string and not Boolean. Hence D is the right answer
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...