Python Question Paper focuses on “Lists”.
Q 1. What will be the output of the following Python code?
print("Hello, World!"[7:]) values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0] for lst in values: for element in lst: if v > element: v = element print(v)
A. 1
B. 3
C. 5
D. 6
Show Answer
Answer:-A. 1Q 2.How many elements are in m?
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
A. 8
B. 12
C. 16
D. 32
Show Answer
Answer:-C. 16Q 3.What will be the output of the following Python code?
values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0] for row in range(0, len(values)): for column in range(0, len(values[row])): if v < values[row][column]: v = values[row][column] print(v)
A. 13
B. 15
C. 16
D 33
Show Answer
Answer:-D. 33Q 4.What will be the output of the following Python code?
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]] for row in values: row.sort() for element in row: print(element, end = " ") print()values = [[3, 4, 5, 1 ], [33, 6, 1, 2]] for row in values: row.sort() for element in row: print(element, end = " ") print()
A. The program prints two rows 3 4 5 1 followed by 33 6 1 2
B. The program prints on row 3 4 5 1 33 6 1 2
C. The program prints two rows 3 4 5 1 followed by 33 6 1 2
D. The program prints two rows 1 3 4 5 followed by 1 2 6 33
Show Answer
Answer:-D. The program prints two rows 1 3 4 5 followed by 1 2 6 33Q 5. What will be the output of the following Python code?
matrix = [[1, 2, 3, 4], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]] for i in range(0, 4): print(matrix[i][1], end = " ")
A.1 2 3 4
B.4 5 6 7
C.1 3 8 12
D.2 5 9 13
Show Answer
Answer:-D. 2 5 9 13Q 6. What will be the output of the following Python code?
points = [[1, 2], [3, 1.5], [0.5, 0.5]] points.sort() print(points)
A.[[1, 2], [3, 1.5], [0.5, 0.5]]
B.[[3, 1.5], [1, 2], [0.5, 0.5]]
C.[[0.5, 0.5], [3, 1.5], [1, 2]]
D.[[0.5, 0.5], [1, 2], [3, 1.5]]
Show Answer
Answer:-D. [[0.5, 0.5], [1, 2], [3, 1.5]]Q 7. What will be the output of the following Python code?
def m(list): v = list[0] for e in list: if v < e: v = e return v values = [[3, 4, 5, 1], [33, 6, 1, 2]] for row in values: print(m(row), end = " ")
A. 3 33
B.11
C.56
D.5 33
Show Answer
Answer:-D. 5 33Q 8. What will be the output of the following Python code?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] print(data[1][0][0])
A.1
B.2
C.4
D.5
Show Answer
Answer:-D. 5Q 9. What will be the output of the following Python code?
m = [[x, x + 1, x + 2] for x in range(0, 3)]
A.[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
B.[[0, 1, 2], [1, 2, 3], [2, 3, 4]]/div>
C.[1, 2, 3, 4, 5, 6, 7, 8, 9]
D.[0, 1, 2, 1, 2, 3, 2, 3, 4]
Show Answer
Answer:-B. [[0, 1, 2], [1, 2, 3], [2, 3, 4]]Q 10. What will be the output of the following Python code?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] def ttt(m): v = m[0][0] for row in m: for element in row: if v < element: v = element return v print(ttt(data[0]))
A.1
B.2
C.4
D.5
Leave a Reply