📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials NumPy What is NumPy?

What is NumPy?

4 min read Quiz at the end
NumPy provides the ndarray for fast N-dimensional numerical computing without Python loops.

What is NumPy?

NumPy is the fundamental Python library for numerical computing. It provides the ndarray — a fast, memory-efficient N-dimensional array — and mathematical functions that operate on entire arrays without Python loops.

pip install numpy

import numpy as np

# Create arrays
a = np.array([1, 2, 3, 4, 5])
b = np.array([[1, 2, 3], [4, 5, 6]])

print(a.shape)    # (5,)
print(b.shape)    # (2, 3)
print(b.dtype)    # int64
print(b.ndim)     # 2
Topic Quiz · 2 questions

Test your understanding before moving on

1. What is the main advantage of a NumPy ndarray over a Python list?
💡 ndarray stores elements in contiguous typed memory enabling C-speed math on entire arrays.
2. How do you check the shape of a NumPy array?
💡 array.shape returns a tuple of dimensions e.g. (3, 4) for a 3-row, 4-column array.