निम्नलिखित कोड का परिणाम क्या है ? एनपी के रूप में सुन्न आयात करें
What is the output of the following code ? import numpy as np
a = np.array([1,2,3])
print(a.ndim) A
1
B
2
C
3
D
0
Explanation
Let's break down the code:
import numpy as np
a = np.array([1, 2, 3])
print(a.ndim)
ais a 1-dimensional numpy array (since it is a single list with elements[1, 2, 3]).- The
.ndimattribute of a numpy array gives the number of dimensions of the array.
For a = np.array([1, 2, 3]), it is a 1D array, so a.ndim will return 1.
Answer: (A) 1.
Correct Answer: A) 1