Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

Based on the comparison provided in the document, what is a key distinguishing difference between the `break` and `continue` statements in Python loops?
Options
A <code>break</code> is used for conditional execution, while <code>continue</code> is for unconditional jumps.
B <code>break</code> terminates the entire loop, whereas <code>continue</code> terminates only the current iteration of the loop.
Correct Answer
C <code>continue</code> causes early termination of the loop, while <code>break</code> causes early execution of the next iteration.
D <code>break</code> can only be used in <code>for</code> loops, while <code>continue</code> can only be used in <code>while</code> loops.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 104 provides a table differentiating break and continue. The first row explicitly states: "It terminates the execution of remaining iteration of the loop." for break and "It terminates only the current iteration of the loop." for continue. Option B accurately reflects this distinction.

Hint

Focus on the scope of termination: does the statement stop the whole loop or just the current cycle?

Question Info