wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python new

Total questions: 26

Worksheet time: 20mins

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.

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.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

6.

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

7.

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

8.

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

9.
a)
b)
c)
d)

1,2,3,4

10.

what is the name of the variable used in the following code?

a)

counter

b)

print

c)

for

d)

#

11.

What is the output of the following code?

a)

1 2 3 4

b)

1 2 3 4 5

c)

1

d)

5

12.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
13.
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
14.

Which of the following for loops would print the following numbers?

3

5

7

9

a)

for i in range(3, 10, 2):

print(i)

b)

for i in range(3, 9, 2):

print(i)

c)

for i in range(9):

print(i)

d)

for i in range(3,9):

print(i)

15.

What is the value of num when this loop completes?


num = 0

for i in range(2, 8, 2):

num += i

a)

2

b)

8

c)

12

d)

20

16.

What would be the output of the following code:

for i in range(3):

print(i)

a)

1 2 3

b)

i i i i

c)

i i i

d)

0 1 2

17.

A while loop equivalent of the for loop above is

a)
b)
c)
d)
18.

Look at the code below and identify which statement below is true:

a)

Starts at 10, goes up to 100, increases by 10

b)

Starts at 10, goes upto 101, increases by 10

c)

Starts at 1, goes up to 100, increases by 1

d)

Starts at 10, goes up to 10, increases by 10

19.
stores a piece of data, and gives it a specific name
a)
variable
b)
whitespace
c)
interpreter
d)
modulo
20.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
21.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
22.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
23.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
24.
Data type for a whole number
a)
String
b)
Integer
c)
Boolean
d)
Float
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.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code