We have been learning about the basic syntax, functions and packages in python, but we have now to come to an interesting part in python programming which is one of the python package manager known as Numpy python module.
In this article we are going to discuss:
- Getting started with Numpy( what is Numpy )
- Installing Numpy
- Advantages of Numpy
- How to import Numpy
Getting Started with Numpy (what is Numpy)
Numpy (numerical python) is the primary Python package for performing scientific computing. It has very powerful tools for integrating C/C++, linear algebra and N-dimensional array. Despite its simple name, NumPy is a powerful Python package whose main aim is working with arrays and matrices.
Some of the advantages of numpy
Numpy can be used in python programs, the data from the database of another program, an external file or an HTML page can be processed using Numpy.
Numpy also works with pygames (a python package for creating games).
Numpy is used to perform mathematical operations on arrays.
Installing Numpy
Most recent version of Linux already has a ready to install package you can use.
Installation of Numpy is very easy in systems where pip and python have already been installed.
Or
In the case where this installation fails or the case where python is not install in your system, then you can use a python distribution that already in install in like spyder or another, which is the easiest way to get started.
How to import Numpy
Before using a package or library, we have to make it accessible. In other words before we start using Numpy and all its function we have to import it. This can easily be done with the import statement
Note that np is Numpy as it has been shortened to save time and standardised so that anyone working with it can easily understand and run it.
An example of python working as
import numpy as np
arr = np.array([1, 2, 3])print(arr)
The code above creates an array with 3 numbers using numpy and later in prints the array.
OUTPUT
Checking Numpy version
The version of Numpy can be known by using the _version_ command which is found in the attribute.
Example
import numpy as np
print(np.__version__)
OUTPUT
Comments
Post a Comment
Please do not enter any spam link in the comment box.