Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz - 20

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

Guess the correct output of the following string operations


str1 = 'Welcome'

print(str1*2)

a)

WelcomeWelcome

b)

str1str1

c)

Error

d)

None of the above

2.

Write the following output of the following code :

list('Welcome')

a)

['W','e','l','c','o','m','e']

b)

('W','e','l','c','o','m','e')

c)

['welcome']

d)

None of the above

3.

Write the following output of the following code :

>>>L = ['w','e','l','c','o','m','e']

>>>print(len(L))

a)

8

b)

9

c)

7

d)

None

4.

Write the following output of the following code :

>>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”]

>>> print(max(L))

a)

Longest Word

b)

Zee

c)

Error

d)

None

5.

Write the output of the following code :

L=list(“www.learninghpython.com”)

print(L[20 : -1])

a)

['c','o']

b)

['c','o','m']

c)

(com)

d)

Error

e)

None of the above

6.

Write the output of the following code :

>>>L=[“Amit”,”Sumit”,”Naina”]

>>>print(L[-1][-1])

a)

['Sumit']

b)

[a]

c)

[Naina]

d)

None of the above

7.

Write the output of the following code :

L=[0.5 * x for x in range(4)]

print(L)

a)

[0.0, 0.5, 1.0, 1.5]

b)

(0,.5, 1, 1.5)

c)

[0.0, 0.5, 1.0, 1.5, 2.0]

d)

None

8.

Write the output of the following code :

L=[‘a’ * x for x in range(4)]

print(L)

a)

[‘ ‘ , ‘a’ , ‘aa’ , ‘aaa’]

b)

[‘a’, ‘aa’, ‘aaa’]

c)

Error

d)

None of the above