NumPy – Getting Started

NumPy is a powerful library for numerical computing in Python that provides efficient data structures and a wide range of mathematical functions. Whether you’re a beginner stepping into the world of coding or an enthusiast interested in exploring the capabilities of numerical computing, this blog post will serve as a beginner’s guide to coding with NumPy. Get ready to unlock the power of numerical computing in Python!

Learn how to install the NumPy package and write a Python program using it in this getting started guide for NumPy.

Install NumPy Library:

Installing the NumPy package is a breeze if you already have Python installed. If Python isn’t on your laptop, follow our How to Install Python 3 on Windows, macOS, and Linux: Step-by-Step Guide before proceeding.

To install NumPy package, from the command line type the below command and press enter to install the NumPy package.

pip install numpy

After successful installation, the message “Successfully installed numpy-x.xx.x” message would be printed in the command line.

To verify the NumPy installation, from the command line type python and enter which will get into python cli. Enter the below code line by line which python compiler prints the installed numpy version.

>>> import numpy as np
>>> print(np.__version__)

Explanation:

  1. In line 1, we are importing NumPy package as np. Now the NumPy package can be referred to as np instead of NumPy. Here np is an alias name which is universally accepted alias for NumPy package. Feel free to change it in your project.
  2. In line 2, we are using the NumPy attribute in the package
  3. Alias can be created for a python package using as keyword

In this tutorial, we had installed the NumPy package and wrote a small program to check the version of the package. In the next article we will explore and understand creating arrays using NumPy package. In meantime do checkout the NumPy official documentation.

References:

  1. NumPy