code for dimensions in numpy

import numpy as np

arr = np.array([1, 2, 3, 4])
arr_2D = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])

print(arr.ndim)
print(arr_2D.ndim)

Here is what the above code is Doing:
1. We created a 1D array using the np.array() method.
2. We created a 2D array using the np.array() method.
3. We printed the dimension of the 1D array using the .ndim attribute.
4. We printed the dimension of the 2D array using the .ndim attribute.