15
QuizMultiple Choice

Use Data Structures — Cumulative exam

Question 15 • Introduction to Information Technology - EL3701

Python programmers use the Else statement to run code

Answer
A
when all the conditions in the preceding If and Elif statements evaluate as False.
B
when the first condition evaluates as True and the second condition evaluates as False.
C
when the code needs to be executed every time the program is run.
D
when the code needs to be executed for conditions that evaluate as True.

Explanation

An else block runs only when none of the preceding if or elif conditions is true. In other words, all those conditions evaluate as False, so the correct choice is “when all the conditions in the preceding If and Elif statements evaluate as False.”

AI-written and checked against the verified answer.

Previous
Next