1import numpy as np
2
3arr = np.array([1, 2, 3, 4])
4arr_2D = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
5
6print(arr.ndim)
7print(arr_2D.ndim)
1numpy.array([0] * n) #creates an int64 numpy array of size n with each element having a vaule of 0
2numpy.array([0] * n, dtype = '<type>') #creates a numpy array of size n with a type of <type>
1>>> x = np.zeros((3, 5, 2), dtype=np.complex128)
2>>> x.size
330
4>>> np.prod(x.shape)
530
6
1import numpy as np
2x = np.array([1,2,3], dtype=np.float64)
3print("Size of the array: ", x.size)
4print("Length of one array element in bytes: ", x.itemsize)
5print("Total bytes consumed by the elements of the array: ", x.nbytes)
6
7