Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

What is the effect of the continue statement in a loop in Python?
Options
A It terminates the loop entirely.
B It resumes the control of the program to the next iteration of the loop, skipping remaining statements in the current iteration.
Correct Answer
C It raises an error and stops the program.
D It executes the loop body multiple times.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 97 explains: 'The continue statement returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop.'

Hint

This statement is used to skip part of the current loop iteration and move to the next one.

Question Info