250+ TOP MCQs on Python Lists and Answers

Python Question Paper on “Lists”.

1. What will be the output of the following Python code?

  1. >>>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]]
c) [1, 2, 3, 4, 5, 6, 7, 8, 9]
d) [0, 1, 2, 1, 2, 3, 2, 3, 4]

Answer: b
Clarification: Execute in the shell to verify.

2. How many elements are in m?

  1. m = [[x, y] for x in range(0, 4) for y in range(0, 4)]

a) 8
b) 12
c) 16
d) 32

Answer: c
Clarification: Execute in the shell to verify.

3. What will be the output of the following Python code?

  1. values = [[3, 4, 5, 1], [33, 6, 1, 2]]
  2. 
    
  3. v = values[0][0]
  4. for row in range(0, len(values)):
  5.     for column in range(0, len(values[row])):
  6.         if v < values[row][column]:
  7.             v = values[row][column]
  8. 
    
  9. print(v)

a) 3
b) 5
c) 6
d) 33

Answer: d
Clarification: Execute in the shell to verify.

4. What will be the output of the following Python code?

  1. values = [[3, 4, 5, 1], [33, 6, 1, 2]]
  2. 
    
  3. v = values[0][0]
  4. for lst in values:
  5.     for element in lst:
  6.         if v > element:
  7.             v = element
  8. 
    
  9. print(v)

a) 1
b) 3
c) 5
d) 6

Answer: a
Clarification: Execute in the shell to verify.

5. What will be the output of the following Python code?

  1. values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]
  2. 
    
  3. for row in values:
  4.     row.sort()
  5.     for element in row:
  6.         print(element, end = " ")
  7.     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

Answer: d
Clarification: Execute in the shell to verify.

  250+ TOP MCQs on Built-in Functions and Answers

6. What will be the output of the following Python code?

  1. matrix = [[1, 2, 3, 4],
  2.        [4, 5, 6, 7],
  3.        [8, 9, 10, 11],
  4.        [12, 13, 14, 15]]
  5. 
    
  6. for i in range(0, 4):
  7.     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

Answer: d
Clarification: Execute in the shell to verify.

7. What will be the output of the following Python code?

  1. def m(list):
  2.     v = list[0]
  3.     for e in list:
  4.       if v < e: v = e
  5.     return v
  6. 
    
  7. values = [[3, 4, 5, 1], [33, 6, 1, 2]]
  8. 
    
  9. for row in values:
  10.     print(m(row), end = " ")

a) 3 33
b) 1 1
c) 5 6
d) 5 33

Answer: d
Clarification: Execute in the shell to verify.

8. What will be the output of the following Python code?

  1. data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
  2. 
    
  3. print(data[1][0][0])

a) 1
b) 2
c) 4
d) 5

Answer: d
Clarification: Execute in the shell to verify.

9. What will be the output of the following Python code?

  1. data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
  2. 
    
  3. def ttt(m):
  4.     v = m[0][0]
  5. 
    
  6.     for row in m:
  7.         for element in row:
  8.            if v < element: v = element
  9. 
    
  10.     return v
  11. 
    
  12. print(ttt(data[0]))

a) 1
b) 2
c) 4
d) 5

Answer: c
Clarification: Execute in the shell to verify.

10. What will be the output of the following Python code?

  1. points = [[1, 2], [3, 1.5], [0.5, 0.5]]
  2. points.sort()
  3. 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], [1, 2], [3, 1.5]]
d) [[0.5, 0.5], [3, 1.5], [1, 2]]

Answer: c
Clarification: Execute in the shell to verify.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top