Report Bug

Qus

What will be the output of the following Python code?

  A = [[1, 2, 3],       [4, 5, 6],       [7, 8, 9]]  [A[i][len(A)-1-i] for i in range(len(A))]
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. [1, 5, 9]
B. [4, 5, 6]
C. [3, 5, 7]
D. [2, 5, 8]


Solution
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.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad