निम्नलिखित कोड के लिए आउटपुट क्या होगा?
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
1
B
3
C
9
D
4
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:
ais a 2D NumPy array with the shape(3, 3)— it has 3 rows and 3 columns.- The
.sizeattribute 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
Correct Answer: C) 9