WorksheetsPS Unit 4 Iteration Quiz Review
Total questions: 30
Worksheet time: 20mins
This variable keeps a count how many times a loop executes successfully
count variable
loop variable
loop control variable
All of these
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
WHILE loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to $100.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a program that will keep letting me add a regular monthly payment for 12 months.
FOR Loop
WHILE Loop
Look at the code below and identify which statement below is true:
Starts at 10, prints numbers to 100, increases by 10
Starts at 10, prints numbers to 101, increases by 10
Starts at 1, prints numbers to 100, increases by 1
Starts at 10, prints numbers to 10, increases by 10
________ loop executes a sequence of instructions endlessly.
for loop
while loop
infinite loop
None of these
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
What is one way to end a loop?
count controlled
print controlled
function controlled
assignment controlled
if you want a loop to repeat 3 times what should you use?
for counter in range(4):
for counter in range(1,3):
for counter in range(3):
for counter in range(0,4):
what is the name of the loop control variable used in the following code?
counter
for
range
A condition is
a statement that is either True or False
a string
an integer
a list
Which kind of loop would be used?
I need a guessing game program that will let me keep guessing until I get the right answer.
FOR Loop
WHILE Loop
word= "computer"
for num in range(1,6):
print(word)
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print(i)
for i in range(3, 9, 2):
print(i)
for i in range(9):
print(i)
for i in range(3,9):
print(i)
Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?
for i in range(0, 5):
for i in range(5):
for i in range(0, 5, 1):
for i in range(5, 0, 1):
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
What is the output of this code?
It would print 'So good to see you' infinite number of times
There would be no output
It would print an error message.
It would print 'Enter correct code'.
What is the final value printed?
(a)
To increment means to
increase the value of a variable
decrease the value of a variable
add 1 to the variable
subtract 1 from the variable
What is the output?
12 9 6 3 0
0 3 6 9 12
0 3 6 9
9 6 3 0
What is the output?
12 17 22
12
5
5 10
What is the output?
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
Hello world!
Hello world!
break
Error
