What is the output of the following code ? import numpy as np a = np.array([[1,2,3]]) print(a.shape)(2,3)None of the above(3,1)(1,3)
Question
What is the output of the following code ? import numpy as np a = np.array([[1,2,3]]) print(a.shape)(2,3)None of the above(3,1)(1,3)
Solution
The output of the code will be (1,3). This is because the numpy array 'a' is a 1-dimensional array with 3 elements. The 'shape' attribute of a numpy array returns a tuple representing the dimensionality of the array. In this case, it is (1,3) because there is 1 row and 3 columns.
Similar Questions
Q.13 What will be output for the following code?import numpy as npa = np.array([1,2,3])print a
30. What does the following Python code output? import numpy as np a = np.array([[1, 2], [3, 4], [5, 6]]) print(a[:, 1]) [1, 3, 5][1, 4, 5][2, 3, 6][2, 4, 6]
What does the shape attribute of a NumPy array represent?
what is the result of the following lines of code:a=np.array([0,1])b=np.array([1,0])print( a @b )
Output of the below snippet: import numpy as np a=np.array([100,2,300,]) print(a[0],a[2])
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.