Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PS Unit 4 Iteration Quiz Review

Total questions: 30

Worksheet time: 20mins

Name
Class
Date
1.

This variable keeps a count how many times a loop executes successfully

a)

count variable

b)

loop variable

c)

loop control variable

d)

All of these

2.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

3.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

4.

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.

a)

FOR Loop

b)

WHILE Loop

5.

Which kind of loop would be used?

I need a program that will keep letting me add a regular monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

6.

Look at the code below and identify which statement below is true:

a)

Starts at 10, prints numbers to 100, increases by 10

b)

Starts at 10, prints numbers to 101, increases by 10

c)

Starts at 1, prints numbers to 100, increases by 1

d)

Starts at 10, prints numbers to 10, increases by 10

7.

________ loop executes a sequence of instructions endlessly.

a)

for loop

b)

while loop

c)

infinite loop

d)

None of these

8.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

9.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

10.
a)
b)
c)
d)

1,2,3,4

11.

What is one way to end a loop?

a)

count controlled

b)

print controlled

c)

function controlled

d)

assignment controlled

12.

if you want a loop to repeat 3 times what should you use?

a)

for counter in range(4):

b)

for counter in range(1,3):

c)

for counter in range(3):

d)

for counter in range(0,4):

13.

what is the name of the loop control variable used in the following code?

a)

counter

b)

print

c)

for

d)

range

14.
What type of loop is used when you know how many times you want to repeat something?
a)
A WHILE Loop
b)
An IF function
c)
A FOR Loop
d)
A Variable
15.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

16.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
17.

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.

a)

FOR Loop

b)

WHILE Loop

18.
What is the word used to describe repetition in programming?
a)
Sequence
b)
Selection
c)
Iteration
d)
Coding
19.
What are the two main types of loops that we have learned about in Python?
a)
IF Function & Variables
b)
FOR and WHILE Loops
c)
Forever and Fixed Loop
d)
Data Types and Numbers
20.
How many times does the following program print the word ‘computer’:

word= "computer"  
for num in range(1,6):
 
    print(word)
a)
5
b)
6
c)
1
d)
0
21.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
22.

Which of the following for loops would print the following numbers?

3

5

7

9

a)

for i in range(3, 10, 2):

print(i)

b)

for i in range(3, 9, 2):

print(i)

c)

for i in range(9):

print(i)

d)

for i in range(3,9):

print(i)

23.

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

a)

for i in range(0, 5):

b)

for i in range(5):

c)

for i in range(0, 5, 1):

d)

for i in range(5, 0, 1):

24.

What would be the output of the following code:

for i in range(3):

print(i)

a)

1 2 3

b)

i i i i

c)

i i i

d)

0 1 2

25.

What is the output of this code?

a)

It would print 'So good to see you' infinite number of times

b)

There would be no output

c)

It would print an error message.

d)

It would print 'Enter correct code'.

26.

What is the final value printed?

(a)  

27.

To increment means to

a)

increase the value of a variable

b)

decrease the value of a variable

c)

add 1 to the variable

d)

subtract 1 from the variable

28.

What is the output?

a)

12 9 6 3 0

b)

0 3 6 9 12

c)

0 3 6 9

d)

9 6 3 0

29.

What is the output?

a)

12 17 22

b)

12

c)

5

d)

5 10

30.

What is the output?

a)

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

(repeated continuously)

b)

Hello world!

c)

Hello world!

break

d)

Error