wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python 3 Loops

Total questions: 55

Worksheet time: 2hrs 30mins

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.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
5.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
6.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
7.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
8.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
9.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
10.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
11.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
12.
a)
10  8  6  4  2
b)
10
8
6
4
2
c)
2  4  6  8  10
d)
10  9  8  7  6  5  4  3  2  1
13.
a)
12  9  6  3  0
b)
0  3  6  9  12
c)
9  6  3  0
d)
0  3  6  9
14.
a)
0  5  10
b)
5  10
c)
0  5  10  15  20  25  30  35  40  45  50  55  60  65  70  75  80  85  90  95  100  105  110  115  120  125  130  135  140......etc
d)
12  7  2
15.
a)
12  17   22
b)
5
c)
12
d)
5  10
16.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
17.
a)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
b)
Hello world!
c)
Hello world!
break              
d)
Error
18.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
19.
a)
Welcome
b)
Try again!
c)
Error
d)
Enter your password
20.
a)
Hello world!
b)
Error
c)
Hello world!
False
d)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
21.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
22.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
23.
Data type that can only be true or false
a)
int
b)
string
c)
bool
d)
float
24.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
25.
To solve a problem that requires the user to enter 10 numbers would use what type of iteration?
a)
While loop
b)
For loop
c)
Variable
d)
Selection
26.

In a Python program, what would be the iteration variable (looping variable) in the FOR LOOP code?

a)

n

b)

num

c)

value

d)

i

27.

In a Python program, what would be the iteration variable (looping variable) in the WHILE LOOP code?

a)

w

b)

y

c)

z

d)

i

28.

In a Python program, what would be the starting value in the FOR LOOP code?

a)

100

b)

10

c)

5

d)

20

29.

In a Python program, what would be the starting value in the FOR LOOP code?

a)

25

b)

4

c)

1

d)

0

30.

In a Python program, what would be the starting value in the WHILE LOOP code?

a)

20

b)

5

c)

2

d)

15

31.

In a Python program, what would be the starting value in the WHILE LOOP code?

a)

50

b)

3

c)

5

d)

10

32.

In a Python program, what would be the starting value in the WHILE LOOP code?

a)

6

b)

1

c)

0

d)

10

33.

In a Python program, what would be the ending value in the WHILE LOOP code?

a)

0

b)

5

c)

2

d)

20

34.

In a Python program, what would be the ending value in the WHILE LOOP code?

a)

5

b)

50

c)

10

d)

3

35.

In a Python program, what would be the increment value for the looping variable in the WHILE LOOP code?

a)

5

b)

3

c)

-5

d)

1

36.

In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?

a)

15

b)

7

c)

10

d)

1

37.

In a Python program, what would be the ending value in the FOR LOOP code?

a)

15

b)

1

c)

10

d)

100

38.

In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?

a)

15

b)

1

c)

3

d)

5

39.

In a Python program, what would be the increment value for the looping variable in the WHILE LOOP code?

a)

30

b)

1

c)

-3

d)

-10

40.

In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?

a)

-100

b)

1

c)

5

d)

-5

41.

In a Python program, how many iterations(loops) will occur for the FOR LOOP code?

a)

1

b)

10

c)

9

d)

8

42.

In a Python program, how many outputs will occur for the snippet of code?

a)

15

b)

3

c)

6

d)

5

43.

In a Python program, how many outputs will occur for the snippet of code?

a)

5

b)

2

c)

8

d)

4

44.
A loop repeated if the condition is true / false
a)
While loop
b)
For loop
c)
Repeat loop
d)
If...else
45.
Loop executed a fixed number of times with a built-in-counter (creating a counter variable is unnecessary).
a)
While loop
b)
For loop
c)
Repeat loop
d)
If...else
46.
Consider the loop control structure in programming. Which term describes a loop that continues repeating without a terminating (ending) condition?
a)
Conditional Loop
b)
Unlimited Loop
c)
Sequence Loop
d)
Infinite Loop
47.
What will print?
a)
1
2
11
b)
1
2
21
c)
1
2
3
11
d)
1
2
3
21
48.
What will print to the screen?
a)
0
b)
2
c)
3
d)
1
49.
What will print to the screen in this code?
a)
18
b)
-25
c)
-10
d)
-15
50.
Which of the following can complete the code so that 6.0 prints to the screen?
a)
* 3 / 2
b)
+ 1
c)
/ 0.5
d)
+ 3 * (1/ 2)
51.
Which of the following will print:
a)
for i in range(1, 5):   
print(str(i) * 5)
b)
for i in range(1, 5):   
print("i" * i)
c)
for i in range(1, 6):   
print("i" * i)
d)
for i in range(1, 6):   
print(str(i) * i)
52.
What is the output from this code snippet?
a)
1, 0, 1, 1, 0, 1, 1, 1, 1, 1
b)
0, 1, 1, 0, 1, 1, 0, 1, 1, 0
c)
0, 1, 1, 0, 1
d)
0, 1, 1, 1, 1, 1, 0, 1, 1, 0
53.
What is the output from this code snippet?
a)
3
b)
2
c)
1
d)
4
54.
What should replace the two empty spaces in order to get the output: -1, -0.5, 0.0 1.0, 2.0, 3.0, 3.5, 4.0
a)
-6, 5
b)
6, -0.5
c)
5, 1.5
d)
6, 0.5
55.
What is the output from this code snippet?
a)
5
b)
4
c)
3
d)
2