NUMPY BASIC EXERCISE 12
Find out the memory size of a numpy array
In this exercise, we are going to find the size of an array in memory.
Code
import numpy as np arr = np.array([1,2,3,4,5,6,7,8,9,10]) print("Initial array:") print(arr) print("Size of the array in memory:") print(arr.size * arr.itemsize)
Output
import numpy as np
arr = np.array([1,2,3,4,5,6,7,8,9,10])
print("Initial array:")
print(arr)
print("Size of the array in memory:")
print(arr.size * arr.itemsize)