Loading

Quipoin Menu

Learn • Practice • Grow

NumPy

NumPy (Numerical Python) is the fundamental package for scientific computing in Python. It provides a powerful N‑dimensional array object, fast operations, and mathematical functions. It is the basis for many other data science libraries.

Installation
`pip install numpy`

Creating Arrays
Use `np.array()` from lists, or convenience functions.


import numpy as np

a = np.array([1, 2, 3])
b = np.zeros((3, 3))
c = np.ones((2, 3))
d = np.arange(10)
e = np.linspace(0, 1, 5)

Array Operations
Vectorized operations are fast.


arr = np.array([1, 2, 3])
arr2 = arr * 2 # [2,4,6]
arr3 = arr + 10 # [11,12,13]
mean = np.mean(arr)
total = np.sum(arr)

Indexing and Slicing
Similar to lists but supports fancy indexing.


matrix = np.array([[1, 2], [3, 4]])
print(matrix[0, 1]) # 2
print(matrix[:, 0]) # [1,3]

Broadcasting
Perform operations on arrays of different shapes.
Two Minute Drill
  • NumPy provides fast, vectorized operations on arrays.
  • Create arrays with `np.array()`, `np.zeros()`, `np.arange()`.
  • Operations are element‑wise and efficient.
  • Slicing works like Python lists; fancy indexing is powerful.
  • Broadcasting allows operations on different shapes.

Need more clarification?

Drop us an email at career@quipoinfotech.com