6.6 Break Flashcards

1
Q

What is nested control statement?

A

When we use multiple control flow tools it is called nested control statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When is the break keyword used?

A

When we want to exit the loop when a certain condition is met

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a syntax using break loop

A
j=0
for i in range (5): 
   j=j+2
   print('i=',i,'j=',j)
   if j ==6:
   break

The answer is
i= 0 j= 2
i= 1 j= 4
i= 2 j= 6

It stops executing when the answer reaches 6 as the value for J

How well did you know this?
1
Not at all
2
3
4
5
Perfectly