Question Detail

COS 102 If staments Objective Question

Question

What is the primary function of the else clause in an if-else statement?
Options
A To provide an alternative action if the <code>if</code> condition is True.
B To provide a backup plan if the <code>if</code> condition is False.
Correct Answer
C To define a loop that repeats indefinitely.
D To compare multiple conditions simultaneously.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 8, 'The 'Else' Clause (The Backup)', states: 'What if the condition is False? We can provide a backup plan using else.'

Hint

Consider what happens when the initial 'if' condition is NOT met.

Question Info