29
QuizMultiple Choice

Test: Design and Development

Question 29 • SC-Fundamentals of Computing - Content Recovery - Design & Development

How do you exit the loop completely so that the next line of code executed is "print("Done")? for n in range(5): square = n ** 2 if square == 9: _____ print(square) print("Done")

Answer
A
continue
B
exit
C
break
D
quit

Explanation

Use `break` to stop the loop as soon as `square == 9`. When `n` is 3, `square` is 9, so `break` exits the loop and execution continues at `print("Done")`. `continue` would only skip to the next loop iteration, while `exit` and `quit` are not the loop-control statement needed here.

AI-written and checked against the verified answer.

Previous
Next