निम्नलिखित कोड के लिए आउटपुट क्या होगा?
What will be output for the following code ?
import numpy as np
a = np.array([[1,2,3],[0,1,4],[11,22,33]])
print (a.size)
A)
B)
C)
D)
Explanation:
In the given code:
import numpy as np
a = np.array([[1, 2, 3], [0, 1, 4], [11, 22, 33]])
print(a.size)
Explanation:
a
is a 2D NumPy array with the shape(3, 3)
— it has 3 rows and 3 columns.- The
.size
attribute of a NumPy array gives the total number of elements in the array.
Since the array a
has 3 rows and 3 columns, the total number of elements is:
3 * 3 = 9
Answer: (C) 9