NumPy Basics

Install NumPy

If you have already installed Python and PIPThen, installing NumPy is very easy.

Please use this command to install it:

C:\Users\Your Name>pip install numpy

If this command fails, please use a python distribution that has NumPy installed, such as Anaconda, Spyder, etc.

Import NumPy

After installing NumPy, add import Keyword to import it into your application:

import numpy

Now, Numpy has been imported and can be used.

Example

import numpy 
arr = numpy.array([1, 2, 3, 4, 5]) 
print(arr)

Run Instance

NumPy as np

NumPy is usually called np Alias Import.

Alias: In Python, an alias is an alternative name used to refer to the same thing.

Please use the alias when importing as Keyword to create an alias:

import numpy as np

Now, you can call the NumPy package np instead of numpy.

Example

import numpy as np 
arr = np.array([1, 2, 3, 4, 5]) 
print(arr)

Run Instance

Check NumPy Version

The version string is stored in __version__ in properties.

Example

import numpy as np
print(np.__version__)

Run Instance