wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

for loops

Total questions: 7

Worksheet time: 5mins

Name
Class
Date
1.

This statement is used to allow a program to repeat a task for a specific number of times

a)

if

b)

for

c)

while

2.

range() function is used to create a sequence of numbers.

Write the range() function to create this sequence: [0, 1, 2, 3, 4]

a)

range(0, 1, 2, 3, 4)

b)

range(5)

c)

range(4)

d)

range(0, 4)

3.

range() function is used to create a sequence of numbers.

Write the range() function to create this sequence: [2, 3, 4, 5, 6]

a)

range(2, 3, 4, 5, 6)

b)

range(2, 6)

c)

range(2, 7)

d)

range(5)

4.

range() function is used to create a sequence of numbers.

Write the range() function to create this sequence: [2, 4, 6, 8]

a)

range(2, 4, 6, 8)

b)

range(2, 8)

c)

range(2, 9)

d)

range(2, 9, 2)

e)

range(2, 8, 2)

5.

What will be displayed after the program is executed?

a)

1 2 3 4 5

b)

1

2

3

4

5

c)

0 1 2 3 4

d)

0

1

2

3

4

6.

What will be displayed after the program is executed?

a)

0

1

2

3

4

5

b)

1

2

3

4

5

c)

1

2

3

4

5

6

d)

0

1

2

3

4

7.

What will be displayed after the program is executed?

a)

2

15

3

b)

2

5

8

11

14

c)

Hi

Hi

Hi

Hi

Hi

d)

Hi

Hi

Hi

e)

my brain hurts