Python arrays using numpy

numpy is a package that contains several classes, functions, variables etc. to deal with scientific calculations in Python. numpy is useful to create and also process single and multi-dimensional arrays. In addition, numpy contains a large library of mathematical functions like linear algebra functions and Fourier transforms.

To work with numpy, we should first import numpy module into our Python programs as:

import numpy

we can use any of the objects from that package. But, to refer to an object we should use the format:numpy.object.

Installing numpy

pip install numpy

screen represents pip installing process

Python program to create a simple array using numpy.

Second version of Program to create an array.

Third version of Program to create an array.

Creating arrays in numpy can be done in several ways. Some of the important ways are:

  • Using array() function
  • Using linspace() function
  • Using logspace() function
  • Using arange() function
  • Using zeros() and ones() functions