21. What will be the output of the following Python code?
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)
22. What will be the output of the following Python code?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
print(data[1][0][0])
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
print(data[1][0][0])
23. What will be the output of the following Python code?
numbers = [1, 2, 3, 4]
numbers.append([5,6,7,8])
print(len(numbers))
numbers = [1, 2, 3, 4]
numbers.append([5,6,7,8])
print(len(numbers))
24. Write a list comprehension to produce the list: [1, 2, 4, 8, 16......212].
25. Which of the following matrices will throw an error in Python?
26. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?
27. 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]]
[[col1 * col2 for (col1, col2) in zip(row1, row2)] for (row1, row2) in zip(A, B)]
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
[[col1 * col2 for (col1, col2) in zip(row1, row2)] for (row1, row2) in zip(A, B)]
28. What will be the output of the following Python code?
>>>"Welcome to Python".split()
>>>"Welcome to Python".split()
29. What will be the output of the following Python code?
num = ['One', 'Two', 'Three']
for i, x in enumerate(num):
print('{}: {}'.format(i, x),end=" ")
num = ['One', 'Two', 'Three']
for i, x in enumerate(num):
print('{}: {}'.format(i, x),end=" ")
30. What will be the output of the following Python code?
>>>list("a#b#c#d".split('#'))
>>>list("a#b#c#d".split('#'))
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.