Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python-loops

Total questions: 11

Worksheet time: 11mins

Name
Class
Date
1.

In programming, what is iteration?

a)

The repetition of steps within a program

b)

The order in which instructions are carried out

c)

A decision point in a program

d)

Testing a program to make sure it works

2.
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
d)
It ensures the code works correctly
3.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
4.
What would amount equal in this piece of code:

amount = 2 + 5 * 2
a)
12
b)
9
c)
14
d)
5
5.
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
6.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
7.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
8.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
9.
a)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
b)
Hello world!
c)
Hello world!
break              
d)
Error
10.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
11.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2