To find the shape of a NumPy array, you can use the shape attribute of the array. This attribute returns the number of rows and columns in the array, represented as a tuple. For example, if the array has 3 rows and 4 columns, the shape
attribute will return the tuple (3, 4)
. You can use the shape
attribute to determine the dimensions of the array and perform various operations on it.
Example