wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PYTHON (FOR LOOP)

Total questions: 10

Worksheet time: 13mins

Name
Class
Date
1.

Choose the correct output of the following code.

for i in range(10,15):       

print(i)

a)

10

11

12

13

14

b)

10

11

12

13

14

15

c)

11

12

13

14

d)

Error

2.

What is the output of the following:-

x = "123"

for i in x:

print("a")

a)

x

1

a

b)

1

2

3

c)

x

1

2

3

d)

a

a

a

3.

Q3. Write a for loop so that every item in the list is printed.

lst=["koala", "cat", "fox", "panda", "chipmunk", "sloth", "penguin", "dolphin"]

4 lines
4.

Q4. What is the output of the following:-

print(list(range(10)))

a)

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

b)

[1,2,3,4,5,6,7,8,9,10]

c)

[2,3,4,5,6,7,8,9,10,11]

d)

[0,1,2,3,4,5,6,7,8,9,10]

5.

Choose the correct answer

for i in "python":

print(i, end=='?')

a)

Error

b)

p?

y?

t?

h?

o?

n?

c)

p?y?t?h?o?n?

d)

both b and c

6.

Find the error and correct it

i=2

for x in (i):

x+=1

print(x)

4 lines
7.

What is for loop.

4 lines
8.

What will be the output of the following Python code?

x = 'abcd'

for i in range(len(x)):

print(i)

a)

1234

b)

abcd

c)

0123

d)

error

9.

What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}

for x in d.values():

print(d[x])

a)

a b c

b)

0 1 2

c)

error

d)

'a' 'b' 'c'

10.

What is the use of Break statement

4 lines