Loading...
Loading...
Test your knowledge of loops
1. What does range(3) generate?
2. After this code, what is total?
total = 0
for n in [1, 2, 3, 4]:
total += n3. What does break do?
4. What does continue do?
5. What does range(5, 10) generate?
6. How many times does this loop run?
for i in range(1, 6):
print(i)7. What's wrong with this code?
total = 0
for n in [1, 2, 3]:
total += n8. What does range(10, 0, -3) generate?
9. What is output?
for n in [1, 2, 3]:
if n == 2:
break
print(n)10. What is output?
for n in [1, 2, 3]:
if n == 2:
continue
print(n)