निम्नलिखित कोड का परिणाम क्या है ?
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
(2, 3)
B
(3, 3)
C
(1,1)
D
None of these
Explanation
The correct answer is:
(B) (3, 3)
Explanation:
- The array
ais a 2D NumPy array with 3 rows and 3 columns:[[1, 2, 3], [4, 5, 6], [7, 8, 9]] - The
.shapeattribute 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)
Correct Answer: B) (3, 3)