Lesson 37 of 55
PythonIntroduction to NumPy
20 minutes
Course progress67%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 37 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
NumPy provides high‑performance N‑dimensional array objects and a vast collection of mathematical functions. It’s the foundation of most Python scientific libraries.
import numpy as np
a = np.array([1, 2, 3])
print('Array:', a)
print('Mean:', a.mean())
# 2‑D array (matrix)
b = np.arange(6).reshape(2, 3)
print('2×3 matrix:
', b)
Operations on NumPy arrays are vectorized, meaning they execute C‑level loops under the hood—much faster than native Python loops.