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

Answer by student:

False

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:

[True or False] “In a Python program, if a break statement is given in - CBSE Class 12 Sample Paper for 2024 Boards

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 .

Remove Ads
Teachoo · Class 12 Explore Class 12
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.