wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Loops

Total questions: 12

Worksheet time: 6mins

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 types whwt 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 is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
9.
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
10.
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.
11.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
12.
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