What will be the output of the following Python code? [code]A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] A[1][/code]

Tam ca

New member
What will be the output of the following Python code?
Code:
A = [[1, 2, 3],
          [4, 5, 6],
          [7, 8, 9]]
A[1]
A. [4, 5, 6]
B. [3, 6, 9]
C. [1, 4, 7]
D. [1, 2, 3]
 
Answer: a
Explanation: We can index the rows and columns using normal index operations. The statement A[1] represents the second row, that is, the middle row. Hence the output of the code will be: [4, 5, 6].
 

Tìm kiếm

Back
Top