CHAPTER 04
Beginner
NumPy Array Operations
Updated: May 18, 2026
5 min read
# CHAPTER 4
NumPy Array Operations
1. Chapter Introduction
NumPy's power comes from operations on entire arrays — no Python loops needed. Element-wise arithmetic, matrix operations, concatenation, and statistics all run at C-speed via vectorization.2. Arithmetic Operations (Element-wise)
python
3. Matrix Operations
python
4. Statistical Operations
python
5. Sorting and Searching
python
6. Concatenation and Splitting
python
7. Mini Project: Student Marks Calculator
python
8. Common Mistakes
-
A * BvsA @ B:*is element-wise,@is matrix multiplication. For linear algebra, always use@ornp.dot().
-
axis=0vsaxis=1: axis=0 operates across rows (column-wise result). axis=1 operates across columns (row-wise result).
9. MCQs
Question 1
a @ b for arrays performs?
Question 2
np.sum(matrix, axis=0) computes?
Question 3
np.argsort(arr) returns?
Question 4
np.vstack([a, b]) stacks?
Question 5
np.cumsum([1,2,3,4]) returns?
Question 6
np.where(arr > 5) returns?
Question 7
arr
Question 8
np.linalg.inv(A) computes?
Question 9
np.hstack([a, b]) stacks?
Question 10
np.argmax(arr) returns?
10. Interview Questions
-
Q: What is the difference between *
and@for NumPy arrays?
-
Q: Explain axis
parameter in NumPy operations.
11. Summary
NumPy array operations are fully vectorized — no loops needed. Arithmetic is element-wise. Matrix multiplication uses @. Statistical functions accept axis to operate row-wise or column-wise. argsort` gives the ranking indices essential for ranked output.