Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. 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))]
  2. A.
    [1, 5, 9]
    B.
    [4, 5, 6]
    C.
    [3, 5, 7]
    D.
    [2, 5, 8]

    View Answer

    Workspace

    Answer : Option C

    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.


Be The First To Comment