wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Loops

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

2.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
3.

The above program prints

a)

Numbers 1 to 10 in reverse order

b)

Numbers 1 to 11 in reverse order

c)

Numbers 1 to 10

d)

Numbers 1 to 11

4.

The program above prints

a)

Numbers between 1 and 100 that are multiples of 5

b)

Numbers between 1 and 100

c)

Numbers between 1 and 100 divisible by 5

d)

Numbers between 1 and 101 that are multiples of 5

5.

The code above prints all numbers between 1 and 30 that are

a)

not divisible by 5

b)

divisible by 5

6.

The program above prints the sum of

a)

all odd numbers less than 100

b)

all even numbers less than 100

c)

all numbers less than 100

7.

The program above prints the sum of all the numbers between 0 and 101 that are

a)

alternate odd numbers

b)

alternate even numbers

c)

alternate numbers

8.

The program above prints each number between 1 and 10

a)

as many times as the number itself

b)

10 times

c)

11 times

9.

The program above prints each number between 1 and 10

a)

as many times as the number itself

b)

10 times

c)

11 times

10.

How many times will 1 be printed

a)

3

b)

4

c)

5

d)

6

11.

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

12.

What is the output of the program above

a)

10

b)

15

c)

18

d)

17

e)

16

13.

A while loop equivalent of the for loop above is

a)
b)
c)
d)
14.

What is the value of the variable sum after the code above executes

a)

54

b)

44

c)

64

d)

34

e)

74

15.

What does this program print

a)

2 + 2 = 4

4 + 4 = 8

8 + 8 = 16

16 + 16 = 32

32 + 32 = 64

b)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

c)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

2 + 10 = 12

d)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

e)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10