निम्नलिखित का आउटपुट क्या होगा?
What will be the output of the following ?
import numpy as np
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
print(a[2,2])
A)
B)
C)
D)
Explanation:
The code creates a 3x4 matrix a
. When you access a[2,2]
, it refers to the element at row 2, column 2 (remember, Python uses 0-based indexing).
Here’s the matrix:
Row 0: [1, 2, 3, 4]
Row 1: [5, 6, 7, 8]
Row 2: [9, 10, 11, 12]
So, a[2,2]
gives the value 11.
Answer: (B) 11