Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

State True or False:

“In a Python program, if a break statement is given in a nested loop, it terminates the execution of all loops in one go.”


Answer by student:


Detailed answer by teachoo:

A break statement in a nested loop only terminates the execution of the innermost loop that contains it. The outer loops continue to execute normally. 

For example, consider the following Python program:

Break Statement Example using a Python Program - Teachoo.png

As we can see, the break statement only terminates the inner loop when i == j, but the outer loop continues to iterate until i reaches 4.

Therefore, the statement is false .

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.