Completed
Flow Control & Loop Challenge
Questions From This Challenge
Q1output1 mark
What will be the output of the following Python code?
x = 5
for i in range(1, 5):
if i == 3:
continue
x = x + i
print(x)
Correct output:
12Q2output1 mark
What will be the output of the following Python code?
total = 0
for i in range(2, 8, 2):
if i == 6:
break
total += i
print(total)
Correct output:
6Q3mcq1 mark
Which statement correctly describes the effect of `pass` when it is encountered inside a loop?
It terminates the loop
It skips the remaining iterations of the loop
It does nothing and execution continues normally ✓
It skips the remaining statements of the program
Q4output1 mark
What will be the output of the following Python code?
for i in range(1, 4):
for j in range(1, 4):
if j == 2:
continue
print(i * j, end=" ")
Correct output:
1 3 2 6 3 9Q5output1 mark
What will be the output of the following Python code?
n = 10
while n > 0:
n -= 2
if n == 4:
break
if n % 3 == 0:
continue
print(n, end=" ")
Correct output:
8 2Q6mcq1 mark
What is the value of `x` after execution of the following code? x = 2 for i in range(1, 4): x *= i + 1
12
24 ✓
36
48
Q7output1 mark
What will be the output of the following Python code?
for i in range(3):
for j in range(3):
if i == j:
print(i, end=" ")
Correct output:
0 1 2Q8output1 mark
What will be the output of the following Python code?
x = 0
for i in range(1, 6):
if i % 2 == 0:
pass
else:
x += i
print(x)
Correct output:
9Q9mcq1 mark
Which value of `n` will make the following condition evaluate to `True`? n % 3 == 0 and n % 5 != 0
10
15
18 ✓
20
Q10output1 mark
What will be the output of the following Python code?
for i in range(2, 5):
for j in range(i):
print(j, end=" ")
Correct output:
0 1 0 1 2 0 1 2 3Q11output1 mark
What will be the output of the following Python code?
s = 0
for i in range(1, 6):
if i == 2:
continue
if i == 5:
break
s += i
print(s)
Correct output:
8Q12output1 mark
What will be the output of the following Python code?
for i in range(1, 4):
for j in range(1, 4):
if i + j == 4:
break
print(i + j, end=" ")
Correct output:
2 3 3Q13mcq1 mark
Which statement will correctly produce the values 2 5 8 11 using `range()`?
range(2, 11, 3)
range(2, 12, 3) ✓
range(2, 11, 2)
range(2, 12, 2)
Q14output1 mark
What will be the output of the following Python code?
x = 0
for i in range(1, 4):
for j in range(1, 4):
if j == 2:
pass
x += i + j
print(x)
Correct output:
36Q15output1 mark
What will be the output of the following Python code?
count = 0
for i in range(1, 5):
for j in range(1, 5):
if i == 3:
break
if j == 2:
continue
count += 1
print(count)
Correct output:
9