Python Array


  • An array type in any programming language offers a continuous storage container for homogenous types.
  • The class array from the array module of Python implements an array type for basic types such as signed and unsigned integers of various lengths (8, 16, 32, 64 and 128 bits), floating point and double precision numbers.
  • Python raises a type error when an attempt is made to store heterogeneous types in an array.


# An example Python program the creates an array of integers

# using the Python module array

import array


# Create an array of integers using the type code 'i'

intArray = array.array('i');


# Insert elements into the Python array

for i in range(10, 0, -1):

     intArray.insert(0, i);


print("Contents of the array:");



print("Address and length of the array:");



print("Size of an element in the array:");



print("The total memory occupied by the array:");





Contents of the array:

array('i', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

Address and length of the array:

(4378146736, 10)

Size of an element in the array:


The total memory occupied by the array:


Copyright 2020 ©