निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
import numpy as np
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(a.shape)
A)
B)
C)
D)
Explanation:
The correct answer is:
(B) (3, 3)
Explanation:
- The array
a
is a 2D NumPy array with 3 rows and 3 columns:[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
- The
.shape
attribute of a NumPy array returns a tuple that gives the dimensions of the array (rows, columns). - In this case, the shape of the array is
(3, 3)
, meaning 3 rows and 3 columns.
Output:
(B) (3, 3)