wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz - 6

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
2.

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

3.

Which of the following is the definition of Indentation in terms of programming

a)

Repetition of a sequence, usually with some change

b)

A gap at the start of a line of code

c)

A line of code that includes a condition, followed by lines of code that only run if the condition is met

d)

Repetition of the first letter at the start of each word in a sentence

4.

What will happen when this program runs

a)

It will display numbers 0-10 on separate lines

b)

It will display numbers 0-9 on separate lines

c)

It will crash

d)

It will display 0s in an infinite loop

5.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
6.

In a While loop a code will be repeated until the condition becomes

a)

FALSE

b)

TRUE

c)

User choice

7.

What would be the output of the following code:

for i in range(3):

print(5)

a)

0 1 2

b)

3 3 3 3 3

c)

5 5 5

d)

0 1 2 3 4

8.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

9.

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

a)

for i in range(0, 5):

b)

for i in range(5):

c)

for i in range(0, 5, 1):

d)

for i in range(5, 0, 1):

10.
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