Quiz Complete, well Done!
How do you exit an infinite loop?
What is the output of the following code?
i = 0
while i < 5:
i += 1
if i == 3:
continue
print(i)
What does the 'continue' statement do in a loop?
In
iteration, the number of iterations is not known in advance.
Which loop is ideal when the number of iterations is unknown?
Conditional loop
What is the purpose of a while loop?
The
statement allows skipping the rest of the current iteration and going to the next one.
What is the syntax of a while loop?
What is the purpose of the 'break' statement in programming?
What is the output of the following code?
i = 0
while True:
print(i)
if i == 5:
break
i += 1
Which loop is ideal when the number of iterations is known?
In which direction does the control flow transfer when a 'break' statement is encountered?
The range function is often used in
loops to iterate over a specific sequence of numbers.
What is the output of the following code?
i = 10
while i > 0:
print(i)
i -= 2
loops occur when the condition of a while loop is always true.
A
loop is an example of indefinite iteration.
Which programming construct is commonly associated with the 'continue' statement?
Break statement
A common method to exit a loop is using the
statement.