Array Module of Python

There are three ways to import the array module into our program.

The first way is to import the entire array module using import statement as,

When we import the array module, we are able to get the 'array' class of that module that helps us to create an array. See the following example:

Here, the first 'array' represents the module name and the next 'array' represents the class name for which the object is created. We should understand that we are creating our array as an object of array class.

The second way of importing the array module is to give it an alias name, as:

Here, the array is imported with an alternate name 'ar'. Hence we can refer to the array class of 'ar' module as:

The third way of importing the array module is to write:

Observe the '*' symbol that represents 'all'. The meaning of this statement is this: import all (classes, objects, variables etc) from the array module into our program. That means we are specifically importing the 'array' class (because of * symbol) of 'array' module. So, there is no need to mention the module name before our array name while creating it. We can create the array as:

Python program to create an integer type array.

Python program to create an integer type array.

A Python program to create an array with a group of characters.