Certified Entry-Level Python Programmer (PCEP-30-02) — Question 37

The following statement ...
assert x == 0

Answer options

Correct answer: D

Explanation

The correct answer is D because the 'assert' statement is used to enforce that a condition holds true; if it does not, it raises an AssertionError, thus stopping the program. Option A is incorrect because if x is 0, the assertion passes and does not stop the program. Options B and C are also wrong as the statement has an effect and is syntactically correct.