निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
What will be the output of the following Python code?
import numpy as np
arr = np.array([1, 2, 3])
print(arr.shape)
A)
B)
C)
D)
Explanation:
The shape
attribute of a NumPy array returns a tuple that represents the dimensions of the array.
For the array arr = np.array([1, 2, 3])
, it is a one-dimensional array with 3 elements.
So, arr.shape
will return (3,)
, indicating a 1-dimensional array with 3 elements.
Answer: (A) (3,)