निम्नलिखित कोड का परिणाम क्या है ? एनपी के रूप में सुन्न आयात करें
What is the output of the following code ? import numpy as np
a = np.array([1,2,3])
print(a.ndim)
A)
B)
C)
D)
Explanation:
Let's break down the code:
import numpy as np
a = np.array([1, 2, 3])
print(a.ndim)
a
is a 1-dimensional numpy array (since it is a single list with elements[1, 2, 3]
).- The
.ndim
attribute 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.