Sail E0 Webinar

MCQs

Total Questions : 11 | Page 2 of 2 pages
Question 11. What is the output of the code shown below?A = [[1, 2, 3],     [4, 5, 6],     [7, 8, 9]][A[i][len(A)-1-i] for i in range(len(A))]
  1.    [1, 5, 9]
  2.    [4, 5, 6]
  3.    [3, 5, 7]
  4.    [2, 5, 8]
 Discuss Question
Answer: Option C. -> [3, 5, 7]


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.


Latest Videos

Latest Test Papers