Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

NumPy Getting Started

Installation of NumPy

If Python and PIP are already installed on your system, installing NumPy is a straightforward process.

Use the following command to install it:

C:\Users\Your Name>pip install numpy

If this command fails, consider using a Python distribution that comes with NumPy pre-installed, such as Anaconda or Spyder.

Import NumPy

After installing NumPy, you can import it into your application by using the import keyword:

import numpy

NumPy is now imported and ready for use.

Example

import numpy

arr = numpy.array([12345])

print(arr)

NumPy as np

NumPy is commonly imported using the alias np.

In Python, an alias is an alternate name used to refer to the same object or entity.

Use the as keyword to create an alias when importing:

import numpy as np

You can now refer to the NumPy package as np instead of numpy.

Example

import numpy as np

arr = np.array([12345])

print(arr)

Checking NumPy Version

The version number is stored in the __version__ attribute.

Example

import numpy as np

print(np.__version__)