Code Explanation:
Importing NumPy:
import numpy as np imports the NumPy library for numerical computations.
Creating a 2D Array:
arr = np.array([[1, 2], [3, 4]]) creates a 2-dimensional NumPy array:
[[1, 2],
[3, 4]]
The array has 2 rows and 2 columns.
Printing the Shape:
arr.shape returns a tuple representing the dimensions of the array.
In this case, the array has:
2 rows
2 columns
So, arr.shape will return (2, 2).
Final Output:
(2, 2)
0 Comments:
Post a Comment