Report Bug

Qus

What will be the output of the following Python code?

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


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


Solution
C. [2, 5, 8]



Explanation
To get a particular column as output, we can simple iterate across the rows and pull out the desired column, or iterate through positions in rows and index as we go. Hence the output of the code shown above is: [2, 5, 8].
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