Introduction To Python Numpy

Anwar Ali
2 min readFeb 26, 2023

--

NumPy is a Python library for scientific computing that provides support for large, multi-dimensional arrays and matrices, along with a large collection of mathematical functions to operate on these arrays. NumPy is one of the most popular libraries in the Python scientific computing ecosystem, and it is widely used in various fields such as physics, engineering, data science, and machine learning.

Photo by Arnold Francisca on Unsplash

NumPy is designed to be efficient in handling large arrays and matrices, and it provides optimized mathematical functions for numerical computations. The core of NumPy is written in C and Fortran, which makes it fast and efficient.

To use NumPy in Python, you first need to install it. You can do this by running the following command in your terminal or command prompt:

pip install numpy

Once you have installed NumPy, you can import it in your Python code using the following line:

import numpy as np

This line imports NumPy and gives it the nickname “np”, which is a commonly used alias in the Python scientific computing community.

Once you have imported NumPy, you can create NumPy arrays using the np.array() function, and you can perform mathematical operations on these arrays using NumPy's built-in functions. Here's an example:

import numpy as np

# Create a NumPy array from a list of numbers
a = np.array([1, 2, 3])

# Create a NumPy array of zeros with shape (3, 3)
b = np.zeros((3, 3))

# Compute the dot product of a and b
c = np.dot(a, b)

print(c)

This code creates a NumPy array a from a list of numbers, creates a NumPy array b of zeros with shape (3, 3), and computes the dot product of a and b using NumPy's np.dot() function. Finally, it prints the result.

--

--

Anwar Ali
Anwar Ali

Written by Anwar Ali

Python Developer | Data Science, Machine Learning Engineer....... Chackout me here: https://www.youtube.com/@GeekySession

No responses yet