31. What will be the output of the following Python code snippet?
x = [i**+1 for i in range(3)]; print(x);
x = [i**+1 for i in range(3)]; print(x);
32. What will be the output of the following Python code?
print(list(zip((1,2,3),('a'),('xxx','yyy'))))
print(list(zip((2,4),('b','c'),('yy','xx'))))
print(list(zip((1,2,3),('a'),('xxx','yyy'))))
print(list(zip((2,4),('b','c'),('yy','xx'))))
33. What will be the output of the following Python code snippet?
34. What will be the output of the following Python code?
l1=[10, 20, 30]
l2=[-10, -20, -30]
l3=[x+y for x, y in zip(l1, l2)]
print(l3)
l1=[10, 20, 30]
l2=[-10, -20, -30]
l3=[x+y for x, y in zip(l1, l2)]
print(l3)
35. Suppose list1 is [1, 3, 2], What is list1 * 2?
36. What will be the output of the following Python code?
def example(L):
''' (list) -> list
'''
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result
def example(L):
''' (list) -> list
'''
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result
37. What will be the output of the following Python code?
a=[1,2,3]
b=a.append(4)
print(a)
print(b)
a=[1,2,3]
b=a.append(4)
print(a)
print(b)
38. 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"])
39. What will be the output of the following Python code?
>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])
>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])
40. To add a new element to a list we use which command?
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.