निम्नलिखित कोड के लिए आउटपुट क्या होगा?
What will be output for the following code ?
import numpy as np
a = np.array([1,2,3,5,8])
print (a.ndim)
A)
B)
C)
D)
Explanation:
Let's break down the code:
import numpy as np
a = np.array([1, 2, 3, 5, 8])
print(a.ndim)
a
is a 1-dimensional numpy array because it's a single list[1, 2, 3, 5, 8]
.- The
.ndim
attribute of a numpy array tells us the number of dimensions of the array.
For the array a = np.array([1, 2, 3, 5, 8])
, it is 1D.
So, the output will be 1
.
Answer: (B) 1.