Lesson 6 of 60 · python
Introduction to NumPy
Duration: 15 minutes
Introduction to NumPy
NumPy (Numerical Python) provides the foundational n‑dimensional array object that powers most scientific Python libraries.
Installing NumPy
pip install numpy
First array
import numpy as np
# Create a 1‑D array from a Python list
arr = np.array([1, 2, 3, 4])
print(arr)
print("Shape:", arr.shape)
print("Data type:", arr.dtype)
Why use NumPy?
- Speed: Vectorized operations are implemented in C.
- Memory efficiency: Homogeneous data types.
- Rich functionality: Linear algebra, Fourier transforms, random sampling, and more.