Completed
Iterative Statements
Questions From This Challenge
Q1mcq1 mark
What is the output of the following code?
total = 0
for i in range(1, 5):
total = total + i
print(total)
10 ✓
15
4
9
Q2mcq1 mark
What is the output of the following code?
i = 1
count = 0
while i <= 10:
count += 1
i += 2
print(count)
5 ✓
10
4
6
Q3mcq1 mark
What is the output of the following code?
count = 0
for i in range(1, 13, 3):
count += 1
print(count)
4 ✓
5
3
6
Q4mcq1 mark
What is the output of the following code?
n = 3
result = 1
while n > 0:
result = result * n
n -= 1
print(result)
6 ✓
3
1
0
Q5mcq1 mark
What is the output of the following code?
total = 0
for i in range(2, 6):
total += i
print(total)
14 ✓
10
6
20
Q6mcq1 mark
What is the output of the following code?
i = 2
count = 0
while i <= 20:
count += 1
i += 3
print(count)
7 ✓
6
8
5
Q7output1 mark
What is the output?
for i in range(1, 4):
print(i * i)
Correct output:
1
4
9Q8output1 mark
What is the output?
n = 5
total = 0
while n > 0:
total += n
n -= 1
print(total)
Correct output:
15Q9output1 mark
What is the output?
for i in range(5, 0, -1):
print(i)
Correct output:
5
4
3
2
1Q10output1 mark
What is the output?
i = 1
while i <= 10:
if i % 2 != 0:
print(i)
i += 1
Correct output:
1
3
5
7
9Q11output1 mark
What is the output?
total = 0
for i in range(3, 15, 4):
total += i
print(total)
Correct output:
3
10
21Q12output1 mark
What is the output?
x = 1
i = 1
while i <= 5:
x = x * 2
i += 1
print(x)
Correct output:
32Q13output1 mark
What is the output?
count = 0
for i in range(1, 20):
if i % 3 == 0:
count += 1
print(count)
Correct output:
6Q14output1 mark
What is the output?
n = 100
while n > 10:
n = n - 15
print(n)
Correct output:
10Q15output1 mark
What is the output?
total = 0
for i in range(1, 6):
total = total + i * 2
print(total)
Correct output:
30