Sail E0 Webinar
Question
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))]
Options:
A .  [1, 5, 9]
B .  [4, 5, 6]
C .  [3, 5, 7]
D .  [2, 5, 8]
Answer: Option C


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.



Was this answer helpful ?

Submit Solution

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

Latest Videos

Latest Test Papers