Skip to main content

How to Import NumPy?

For importing the Numpy Package, we need to install the Numpy Package. After we have done the installation for the Numpy Package, we can now move to Python Prompt and enter the following code to check whether it is working correctly or not.

import Numpy as np 

If you want to check the version, you can enter the following codes.

import numpy as np
np.__version__

Output:

'1.20.1'

If Numpy Package has been installed and imported successfully, you will get output similar to this.  

Why do we use to import NumPy as np?

In Python, we use an alias which is an alternate name for referring to the same thing. Creating an alias is very easy, we can use as  keyword before an alias while importing.
The import as syntax allows us to bind the import to the local variable of our choice. Generally, to avoid using NumPy every time, we can use np. It will be easier for us to call the NumPy function wherever and whenever needed. The NumPy package is bound to the local variable np.

Submitted by devanshi.srivastava on September 8, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.