looping
What is ... when the computer e_____ the s_____ i_____ over and over?
# Hint: The output.
for beans in range(5):
print(beans)
What is ...
0
1
2
3
4
(each number on its own line)?
# Hint: The output.
egg = 0
while egg < 5:
print(egg)
egg = egg + 1
What is ...
0
1
2
3
4
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: The output.
egg = 0
while egg < 5:
print(egg + 5)
egg = egg + 1
What is ...
5
6
7
8
9
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# For 200 points. Hint: The output.
for spam in range(8):
if spam % 3 == 0:
continue
print("*")
What is ...
*
*
*
*
*
(each asterisk or star on its own line)?
[FYI: This code was tested with JDoodle.]
iteration
What is ... the r_____ of a p_____ that moves closer to a s_____?
# Hint: The output.
for beans in range(1, 5):
print(beans)
What is ...
1
2
3
4
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: Not the output.
egg = 0
while egg < 5:
print(egg)
egg = egg + 1
# egg is the ...
What is ... the counter?
# Hint: The output.
my_list = ["a", "b", "c"]
for beans in my_list:
print(beans)
What is ...
a
b
c
(each letter on its own line)?
[FYI: This code was tested with JDoodle.]
# For 400 points. Hint: The output.
ham = ""
for spam in range(8):
if spam % 3 == 0:
continue
ham += "*"
print(ham)
What is ...
*****
(5 asterisks or stars on the same line)?
[FYI: This code was tested with JDoodle.]
A simple for loop that prints
0
1
2
# What is ... ?
for egg in range(3):
print(egg)
# Does not have to use egg.
# Hint: The output.
for beans in range(1, 5, 2):
print(beans)
What is ...
1
3
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: Not the output.
egg = 0
while egg < 5:
print(egg)
egg = egg + 1
# egg < 5 is the ...
What is ... the condition?
Or what is ... the expression?
# Hint: The output.
my_list = [3, 5, 7]
for egg in my_list:
print(egg * "A")
What is ...
AAA
AAAAA
AAAAAAA
(each string on its own line)?
[FYI: This code was tested with JDoodle.]
# For 600 points. Hint: The output.
ham = 0
for beans in range(0, 10):
if beans == 0:
ham = 13
else:
ham -= 1
print(ham)
What is ... 4?
[FYI: This code was tested with JDoodle.]
A simple while loop that prints
0
1
2
# What is ... ?
egg = 0
while egg < 3:
print(egg)
egg = egg + 1
# Does not have to use egg.
# Hint: The output.
for beans in range(5):
print(beans * beans)
What is ...
0
1
4
9
16
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: The output.
spam = 0
while spam < 5:
print(spam + spam)
spam += 1
What is ...
0
2
4
6
8
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: The output.
for bean in range(0, 20, 2):
print(bean)
What is ...
0
2
4
6
8
10
12
14
16
18
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# For 800 points. Hint: The output.
x = 2
y = 1
while (x >= y):
y += x + 1
print(y - x)
What is ... 2?
[FYI: This code was tested with JDoodle.]
A for loop that outputs
5
10
15
20
25
# What is ... ?
for egg in range(5):
print(5 + egg * 5)
# Does not have to use egg.
# FYI: This code was tested with JDoodle.
# Hint: The output.
for egg in range(10):
if egg % 2 == 0:
print(egg)
What is ...
0
2
4
6
8
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: The output.
spam = 4
while spam >= 0:
print(spam + spam)
spam -= 1
# Read the code carefully.
What is ...
8
6
4
2
0
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# Hint: The output.
ham = 3
while ham >= 0:
print(ham)
ham = ham -1
What is ...
3
2
1
0
(each number on its own line)?
[FYI: This code was tested with JDoodle.]
# For 1,000 points. Hint: The output.
num = 5
sum = 0
while True:
if num >= 1:
sum += num
num -= 1
else:
break
print(sum)
What is ... 15?
[FYI: This code was tested with JDoodle.]