1>>> np.shape(np.eye(3))
2(3, 3)
3>>> np.shape([[1, 2]])
4(1, 2)
5>>> np.shape([0])
6(1,)
7>>> np.shape(0)
8()
9
1import numpy as np
2
3arr = np.array([1, 2, 3, 4], ndmin=5)
4
5print(arr)
6print('shape of array :', arr.shape)
1a = np.zeros([2, 3])
2print(a.shape)
3# outputs: (2, 3)
4b = np.random.randn(*a.shape)
5print(b.shape)
6# outputs: (2, 3)
7
1>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
2>>> np.shape(a)
3(2,)
4>>> a.shape
5(2,)
6