wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

For Loops ( Review )

Total questions: 26

Worksheet time: 16mins

Name
Class
Date
1.

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

2.

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

3.
a)
b)
c)
d)

1,2,3,4

4.

When do you know when you come to the end of the loop?

a)

Its states End loop

b)

The command End is given

c)

The indentation stops

5.

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

a)

For counter in range(0,5):

b)

For counter in range(1,3):

c)

For counter in range(0,3):

6.

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

a)

counter

b)

print

c)

for

d)

#

7.

Which of the following is an acceptable variable name?

a)

no-text

b)

8text

c)

no_text

d)

no_text$

8.
What button do you press to compile (run) your program so that it runs in the shell?
a)
F3
b)
F5
c)
F7
d)
F9
9.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
10.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
11.
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
12.

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

13.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
14.

The program above prints

a)

Numbers between 1 and 100 that are multiples of 5

b)

Numbers between 1 and 100

c)

Numbers between 1 and 100 divisible by 5

d)

Numbers between 1 and 101 that are multiples of 5

15.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
16.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
17.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
18.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
19.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
20.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
21.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
22.
A programmer is to a computer as a teacher is to:
a)
a desk 
b)
a student
c)
a library 
d)
a principal
23.
Imagine a car as a computer, and its engine as a program. Which of the following is an input for the engine program?
a)
gas pedal
b)
driver's seat
c)
steering wheel
d)
windshield wipers
24.
A good algorithm must be: 
a)
replacable
b)
simple 
c)
open-ended
d)
detailed
25.
What is wrong with the following "code" for opening a bottle?
1. Grip cap with index finger and thumb
2. Remove cap
3. Twist counter-clock-wise until seal is broken
a)
to many steps
b)
not specific 
c)
function doesn't apply to every bottle 
d)
instructions are out of sequence
26.
A computer program is best described as a series of ___________.
a)
Instructions
b)
Questions
c)
Answers
d)
Numbers