NumPy (Numerical Python) is the foundation of scientific computing in Python. It provides multi-dimensional arrays and high-performance functions to operate on them.
pip install numpy
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr)
matrix = np.array([[1, 2], [3, 4]])
print(arr.shape)
print(arr.dtype)
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(a + b)
print(a * b)
print(a.mean())
arr = np.array([10, 20, 30, 40])
print(arr[1]) # 20
print(arr[1:3]) # [20, 30]
arr = np.arange(6)
arr = arr.reshape(2, 3)
print(arr)
np.sqrt(arr)
np.sum(arr)
np.std(arr)
NumPy is essential for efficient numerical computation and forms the backbone of most data science libraries.
Take quizzes related to this topic and see where you stand!
Start Quiz Now