πŸ“Š Problem Solving and Python Programming
Q. -i] for i in range(len(A))]
  • (A) [1, 5, 9]
  • (B) [4, 5, 6]
  • (C) [3, 5, 7]
  • (D) [2, 5, 8]
πŸ’¬ Discuss
βœ… Correct Answer: (C) [3, 5, 7]

Explanation: this expression scales the common index to fetch a[0][2], a[1][1], etc. we assume the matrix has the same number of rows and columns.

πŸ“Š Problem Solving and Python Programming
Q. ) for col in range(3)]
  • (A) [3, 6, 9, 16, 20, 24, 35, 40, 45]
  • (B) error
  • (C) [0, 30, 60, 120, 160, 200, 300, 350, 400]
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (A) [3, 6, 9, 16, 20, 24, 35, 40, 45]

Explanation: in the code shown above, we have used list comprehension to combine values of multiple matrices. we have multiplied the elements of the matrix b with that of the matrix a, in the range(3). hence the output of this code is: [3, 6, 9, 16, 20, 24,

πŸ“Š Problem Solving and Python Programming
Q. , row2)] for (row1, row2) in zip(A, B)]
  • (A) [0, 30, 60, 120, 160, 200, 300, 350, 400]
  • (B) [[3, 6, 9], [16, 20, 24], [35, 40, 45]]
  • (C) no output
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) [[3, 6, 9], [16, 20, 24], [35, 40, 45]]

Explanation: the list comprehension shown above results in the output: [[3, 6, 9], [16, 20,

Jump to