Online Tutorials & Training Materials |
Register Login

NumPy Introduction

|| 0

NumPy Introduction

This tutorial explains what is NumPy and step by step procedure to use NumPy in Python

What is NumPy?

NumPy is a fundamental package for scientific computing with Python.It is a Python library which adds support for large, multi-dimensional arrays and matrices.

NumPy is an extremely popular Python module which is mostly used for scientific computing. It contains among other things a powerful N-dimensional array object.

How to use Numpy in Python

Please follow the steps below in order to use NumPy:

1) First, download and instal NumPy using pip.

2) Import NumPy module on Python IDLE and create an array.

3) Advantage of NumPy

Using NumPy array is more beneficial than using a simple Python list. Below are the most important benefits of NumPy over Python list

  • It consumes less memory
  • Faster and convenient than Python list

4) Create a Python list and a NumPy array. Compare the memory space allocated in each case. Here, while Python list occupies 14 bytes the NumPy arrays only take up 4 bytes.

5) Add two list of numbers using Python list and NumPy array.

6) Write a program to add two numbers and to calculate the time taken for the program to be executed.

7) Run the program to compare the outputs of each case. NumPy arrays are much faster than Python lists when the array size is very large.

8) NumPy operations can be conducted without writing long, complicated codes. Therefore, it is very convenient to use.

Related Articles