41. What will be the output of the following Python code?
l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
print(i)
l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
print(i)
42. What will be the output of the following Python code?
def increment_items(L, increment):
i = 0
while i < len(L):
L[i] = L[i] + increment
i = i + 1
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)
def increment_items(L, increment):
i = 0
while i < len(L):
L[i] = L[i] + increment
i = i + 1
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)
43. What will be the output of the following Python code?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
zip(A, B)
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
zip(A, B)
44. What will be the output of the following Python code?
a=["Apple","Ball","Cobra"]
a.sort(key=len)
print(a)
a=["Apple","Ball","Cobra"]
a.sort(key=len)
print(a)
45. What will be the output of the following Python code?
veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
veggies.insert(veggies.index('broccoli'), 'celery')
print(veggies)
veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
veggies.insert(veggies.index('broccoli'), 'celery')
print(veggies)
46. What will be the output of the following Python code?
>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2
>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2
47. Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
48. What will be the output of the following Python code?
l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]
l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]
49. What will be the output of the following Python code?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[row][1] for row in (0, 1, 2)]
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[row][1] for row in (0, 1, 2)]
50. What is the output of the following piece of code?
a=list((45,)*4)
print((45)*4)
print(a)
a=list((45,)*4)
print((45)*4)
print(a)
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.