21
What will be the output of the following Python code?
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)
Answer & Solution
Answer: Option
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])
Answer & Solution
Answer: Option
D
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))
Answer & Solution
Answer: Option
B
24
Write a list comprehension to produce the list: [1, 2, 4, 8, 16......212].
Answer & Solution
Answer: Option
A
25
Which of the following matrices will throw an error in Python?
Answer & Solution
Answer: Option
B
26
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?
Answer & Solution
Answer: Option
A
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)]
Answer & Solution
Answer: Option
B
28
What will be the output of the following Python code?
>>>"Welcome to Python".split()
Answer & Solution
Answer: Option
A
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=" ")
Answer & Solution
Answer: Option
D
30
What will be the output of the following Python code?
>>>list("a#b#c#d".split('#'))
Answer & Solution
Answer: Option
A