w3resource
w3resource logo
Python Exercises

Python NumPy: Find the memory size of a NumPy array

Python NumPy: Array Object Exercise-33 with Solution

Write a Python program to find the memory size of a NumPy array.

Pictorial Presentation:

Python NumPy: Find the memory size of a NumPy array

Sample Solution:-

Python Code:

import numpy as np
n = np.zeros((4,4))
print("%d bytes" % (n.size * n.itemsize))

Sample Output:

128 bytes 

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to save a NumPy array to a text file.
Next: Write a Python program to create an array of ones and an array of zeros.