wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Loop

Total questions: 15

Worksheet time: 12mins

Name
Class
Date
1.

An infinite loop is :A loop runs infinite times when the condition-------------.

a)

never fails

b)

run one time

2.

Print i as long as i is less than 6 and i is initiated with the value of 1 :


Which program is correct

a)
b)
3.

In Python while loop It continually executes the statements(code) as long as the given condition is ----------

a)

True

b)

False

4.

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

5.

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

6.

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

7.

Which kind of loop would be used?


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

a)

FOR Loop

b)

WHILE Loop

8.

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

9.
What is another way of writing the following code? 
Score = Score + 1 
a)
Score.add(1)
b)
score + 1
c)
Score + Score
d)
Score += 1
10.
What will the following lines of code print?
a)
A
b)
B
C
c)
A
C
d)
Nothing, it will return an error.
11.

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

12.

numbers = [5, 14, 9, 17]

for number in numbers:

if number % 3 == 0:

print(number)


The output will be?

a)

17

b)

9

c)

14

9

17

d)

14

17

13.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
14.

What is the output of the following code?

i = 5

while i >= 0:

print(i)

i = i - 1

a)

5 4 3 2 1 0

b)

5 4 3 2 1 -1

c)

5 4 3 2 1 -2

d)

5 4 3 2 1 -3

15.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><