NumPy: Find the number of elements of an array, length of one array element in bytes
NumPy: Array Object Exercise-16 with Solution
Write a NumPy program to find the number of elements of an array, length of one array element in bytes and total bytes consumed by the elements
import numpy as np x = np.array([1,2,3], dtype=np.float64) print("Size of the array: ", x.size) print("Length of one array element in bytes: ", x.itemsize) print("Total bytes consumed by the elements of the array: ", x.nbytes)
Size of the array: 3 Length of one array element in bytes: 8 Total bytes consumed by the elements of the array: 24
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a NumPy program to find the real and imaginary parts of an array of complex numbers
Next: Write a NumPy program to test whether each element of a 1-D array is also present in a second array.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
Free up Memory:
- Manual garbage collection can be performed on timely or event based mechanism.
import gc collected_objects = gc.collect()
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework