w3resource

Python: Get the array size of types unsigned integer and float


21. Get the Array Size of Unsigned Integer and Float Types

Write a Python program to get the array size of types unsigned integer and float.

Sample Solution:

Python Code:

from array import array
a = array("I", (12,25))
print(a.itemsize)
a = array("f", (12.236,36.36))
print(a.itemsize)

Sample Output:

4                                                                                                             
4 

For more Practice: Solve these Related Problems:

  • Write a Python program to create an array of unsigned integers and print its itemsize.
  • Write a Python program to create an array of floats and display its total memory size in bytes.
  • Write a Python program to compare the itemsize of arrays of type 'I' and type 'f' and print the difference.
  • Write a Python program to calculate the total buffer size of an array of floats by multiplying its length by its itemsize.

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a Python program to get the length of an array.
Next: Write a Python program to read a string and interpreting the string as an array of machine values.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.