1. What will be the output of the following Python code?
names1 = ['Amir', 'Bala', 'Charlie']
names2 = [name.lower() for name in names1]
print(names2[2][0])
names1 = ['Amir', 'Bala', 'Charlie']
names2 = [name.lower() for name in names1]
print(names2[2][0])
2. What will be the output of the following Python code snippet?
print([[i+j for i in "abc"] for j in "def"])
print([[i+j for i in "abc"] for j in "def"])
3. 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]
l1=[1,2,3]
l2=[4,5,6]
[x*y for x in l1 for y in l2]
4. To remove string "hello" from list1, we use which command?
5. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?
6. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?
7. What will be the output of the following Python code?
b=[2,3,4,5]
a=list(filter(lambda x:x%2,b))
print(a)
b=[2,3,4,5]
a=list(filter(lambda x:x%2,b))
print(a)
8. What will be the output of the following Python code?
points = [[1, 2], [3, 1.5], [0.5, 0.5]]
points.sort()
print(points)
points = [[1, 2], [3, 1.5], [0.5, 0.5]]
points.sort()
print(points)
9. What will be the output of the following Python code?
def f(values):
values[0] = 44
v = [1, 2, 3]
f(v)
print(v)
def f(values):
values[0] = 44
v = [1, 2, 3]
f(v)
print(v)
10. What will be the output of the following Python code?
s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)
s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.