Databricks Certified Data Engineer Associate · Free Practice Question Easy
Question 32
A data engineer has developed a code block to completely reprocess data based on the following if condition in Python:
- if process_mode = "init" and not is_table_exist:
- print("Start processing ...")
This code block is returning an invalid syntax error.
Which of the following changes should be made to the code block to fix this error ?
-
A
- if process_mode == "init" and not is_table_exist:
- print("Start processing ...")
-
B
- if process_mode = "init" & not is_table_exist:
- print("Start processing ...")
-
C
- if process_mode = "init" and is_table_exist = False:
- print("Start processing ...")
-
D
- if (process_mode = "init") and (not is_table_exist):
- print("Start processing ...")
Reveal correct answer
Correct answer: A
Explanation
Python if statement looks like this in its simplest form:
- if <expr>:
- <statement>
Python supports the usual logical conditions from mathematics:
Equals:
a == bNot Equals:
a != b<,<=,>,>=
To combine conditional statements, you can use the following logical operators:
andor
The negation operator in Python is: not
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
