Quiz Complete, well Done!
In which direction does the control flow transfer when a 'break' statement is encountered?
What is the output of the following code?
i = 0
while i < 5:
i += 1
if i == 3:
continue
print(i)
Conditional loop
What is the output of the following code?
i = 4
while i < 10:
print(i)
if i == 7:
break
i += 1
What does the 'continue' statement do in a loop?
Which loop is ideal when the number of iterations is known?
What happens if the condition of a while loop is initially false?
What is the output of the following code?
i = 0
while True:
print(i)
if i == 5:
break
i += 1
Do-while loop
What happens if the condition of a while loop is never true?
When is the 'continue' statement used in programming?
A
loop is an example of indefinite iteration.
What is the output of the following code?
i = 10
while i > 0:
print(i)
i -= 2
Control flow
A for loop is an example of
iteration where the number of iterations is known in advance.
The range function is often used in
loops to iterate over a specific sequence of numbers.
What happens when a 'continue' statement is executed in a loop?
For loop
A common method to exit a loop is using the
statement.
What is a while loop?