A command that will allow code to repeat over and over
What is a Loop?
Unless otherwise specified, for loops start at this number.
0
What/where is the error in the code?:
while coin.upper() != "Done"
coin = input("Insert a coin, Q(Quarter), D(Dime), N(Nickel), or P(Penny). Then type F(Finish) when done. ")
if coin.upper() == "Q":
total = total + Q
elif coin.upper() == "D":
total = total + D
elif coin.upper() == "N":
total = total + N
missing a colon in the while statement
How would a reverse range look like where you print out numbers using a negative step where the start = 5 and the stop = -1
5
4
3
2
1
0
A type of loop that we do not know the exact # of times it will continue for
What is a While Loop
This is the way you phrase a loop that should go 10 times.
What is "for i in range (10)"?
for i in range(4):
print(i)
What will Python print?
0
1
2
3
What should be the condition that is missing from the following code segment:
age = int(input("Enter your age: "))
if ___________:
print("Eligible for voting)"
else:
print("Not eligible for voting")
age >= 18
A While Loop that never ends
What is an Infinite Loop?
What comes after a while loop?
a conditional statement
100
number = 5
if (number > 10):
print("Hello!")
else:
print("Bye-bye")
What will Python print?
Bye-bye
How many times will this loop run?
for i in range(3):
for j in range(5):
print((i+1) * (j+1))
15
A type of loop that only continues for a set amount of times.
What is a For Loop?
A function that repeats a block of code in a specified order, often until a specific result occurs.
What is iteration?
How many times would "meow" print:
for i in range(2, 10, 2):
print("meow")
4
How many times will "meow" print out:
i = 3
while (i > 3):
print("meow")
i -= 1
0
A function that has a start and end value
What is a range?
How many times would this loop run?
x = 0
while x < 5:
x = x + 1
5
This value can be added to the range for a loop to count backwards.
What is -1?
What is the output of the following program:
for i in range (1,11,3):
if i%2==0:
print (i)
4
10