/  Python-List-Quiz

This Quiz contains totally 10 Questions each carry 1 point for you.

1.Find the output of the following code.

nameList = ['i2', 'Tutorials', 'Python', 'MachineLearning']

print ( nameList[1][-1] )
s
P
G
T

Correct!

Wrong!

2.What is the output of the following code?

s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)
[‘a’,’b’,’c’,’d’], [‘a’,’b’,’c’,’d’]
[‘a’,’@’,’b’,’@’,’c’,’@’,’d’] , [‘a’,’b’,’c’,’d’]
[‘a’,’@’,’b@c@d’], [‘a’,’b’,’c’,’d’]
[‘a’,’@’,’b@c@d’], [‘a’,’@’,’b’,’@’,’c’,’@’,’d’]

Correct!

Wrong!

3.What is the output of the following list comprehension?
resList = [x+y for x in ['Hello ', 'Good '] for y in ['Dear', 'Bye']]
print(resList)
[‘Hello Dear’, ‘Hello Bye’, ‘Good Dear’, ‘Good Bye’]
[‘Hello Dear’, ‘Good Dear’, ‘Hello Bye’, ‘Good Bye’]
[‘Hello Bye’, ‘Good Bye’, ‘Hello Dear’, ‘Good Dear’]
[‘Good Dear’, ‘Hello Bye’, ‘Hello Dear’, ‘Good Bye]

Correct!

Wrong!

4.What is the output of the following code?

temp = ['python', 'machinelearning', 'deeplearning']

arr = [i[0].upper() for i in temp]

print(arr)
[‘PYTHON’, ‘MACHINELEARNING’, ‘DEEPLEARNING’]
[‘PYTHON’]
Compilation error
[‘P’, ‘M’, ‘D’]

Correct!

Wrong!

5.What will be the output of the following Python code?

a=[1,2,3]

b=a.append(4)

print(a)

print(b)
[1,2,3,4]; [1,2,3,4]
[1,2,3]; [1,2,3,4]
[1, 2, 3, 4]; None
Syntax error

Correct!

Wrong!

6.In Python, list is mutable.

 
True
False

Correct!

Wrong!

7.What will be the output of the following Python code snippet?

print([i.lower() for i in "HELLO"])
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
‘hello’
[‘hello’]
hello

Correct!

Wrong!

8.What will be the output of the following Python code

l1=[1,2,3]

l2=[4,5,6]

[x*y for x in l1 for y in l2]
[4, 8, 12, 5, 10, 15, 6, 12, 18]
[4, 10, 18]
[4, 5, 6, 8, 10, 12, 12, 15, 18]
[18, 12, 6, 15, 10, 5, 12, 8, 4]

Correct!

Wrong!

9.Output of the following python code is?

list = ['python', 'learning', '@', 'i2', 'tutorials', 'website']

print(list[0:6:2])
[‘python’, ‘@’, ‘tutorials’]
[‘i2, ‘website’, ‘learning’]
[‘python’, ‘learning’, ‘@’, ‘i2, ‘tutorials’, ‘website’]
[‘python’, ‘website]

Correct!

Wrong!

10.Find the output of the below code

list1 = [1, 2, 3, 4, 5]

list2 = list1

list2[0] = 0;

print( list1)
[1, 2, 3, 4, 5, 0]
[0,1, 2, 3, 4, 5]
[0, 2, 3, 4, 5]
[1, 2, 3, 4, 0]

Correct!

Wrong!

Share the quiz to show your results !

Subscribe to see your results

Ignore & go to results

Python-List-Quiz

You got %%score%% of %%total%% right

%%description%%

%%description%%

Where to go ?

Quizzes

Loading...