PYTHON PORGRAM TO DEMONSTARTE SHAPE,SIZE of NUMPY ARRAY

Published: 24 June 2024
on channel: PythonEnthusiasts
46
6

shape : dimensions in form of rows and columns
Size : number of elements in multidimesonal array

import numpy as np
my_arr = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(my_arr)

print("SHAPE OF NUMPY ARRAY:")
print(my_arr.shape)

print("ELEMENTS in NUMPY ARRAY:")
print(my_arr.size)

OUTPUT:
[[1 2 3]
[4 5 6]
[7 8 9]]
SHAPE OF NUMPY ARRAY:
(3, 3)
ELEMENTS in NUMPY ARRAY:
9