Back to Modules

NumPy Tutorial

Learn NumPy essentials for data analytics and scientific computing with hands-on examples.

Video Tutorial

Introduction to NumPy

NumPy is the fundamental package for scientific computing with Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on them.

Examples:

import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr)

Create a simple NumPy array and print it.

Array Operations

NumPy allows you to perform element-wise operations on arrays, making mathematical computations efficient and concise.

Examples:

import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(a + b)  # [5 7 9]
print(a * b)  # [ 4 10 18]

Element-wise addition and multiplication of NumPy arrays.

Array Slicing and Indexing

NumPy arrays can be sliced and indexed in powerful ways, similar to Python lists but with more features.

Examples:

import numpy as np
arr = np.array([10, 20, 30, 40, 50])
print(arr[1:4])  # [20 30 40]

Slice a NumPy array to get a subarray.