Chapter 4: NumPy Syllabus
NumPy syllabus written in the style of an experienced teacher who has taught hundreds of students.
It is structured as a complete self-study or course plan — not just a list of topics, but with:
- estimated time per topic
- learning goals
- difficulty level
- must-do exercises / mini-projects
- recommended order
- common student mistakes & how to avoid them
- why each topic actually matters in real work (2025 perspective)
NumPy Syllabus – From Zero to Confident User (2025 edition)
Total recommended time: 35–70 hours (depending on whether you are a beginner or already know some Python)
Target audience:
- People who want to use NumPy seriously (data analysis, ML, scientific computing, automation, finance, image processing…)
- Beginners to intermediate learners
- People who want to stop writing slow Python loops
Prerequisites
- Comfortable with basic Python (lists, loops, functions, dictionaries)
- No prior NumPy knowledge required
Phase 1 – Foundation (8–16 hours)
Goal: Understand what NumPy actually is and stop being afraid of arrays
1. Why NumPy exists – the honest story (1–1.5 h)
- Python lists vs NumPy arrays (speed, memory, vectorization)
- Broadcasting – the single biggest reason NumPy feels magical
- When you should not use NumPy (small data, non-numeric, strings)
Exercise: Create the same computation with pure Python list + for-loop vs NumPy → time both with %timeit
2. Creating arrays – the 10 most common ways (2–3 h)
Must know:
|
0 1 2 3 4 5 6 7 8 9 10 11 |
np.array([...]) np.zeros(), np.ones(), np.full() np.arange(), np.linspace() np.random.rand / randn / randint / uniform / normal np.eye(), np.diag() np.empty() (dangerous but very fast) |
Exercise: Create 8 different arrays that all contain exactly 100 elements of value 3.14 (different methods)
3. Understanding .shape, .ndim, .size, .dtype, .itemsize, .nbytes (1.5–2 h)
Must be automatic:
|
0 1 2 3 4 5 6 7 8 9 10 11 |
print(a.shape) # tuple print(a.ndim) # 1, 2, 3… print(a.size) # total elements print(a.dtype) # int64, float32, bool, object… print(a.itemsize) # bytes per element print(a.nbytes) # total memory in bytes |
Exercise: Create 5 arrays of different shapes and dtypes → print all 6 properties for each
4. Views vs Copies – the #1 source of surprise & bugs (2–4 h)
Must deeply understand:
|
0 1 2 3 4 5 6 7 8 9 10 11 |
b = a # view (same data) b = a.copy() # deep copy b = a[:] # usually view b = a[::2] # view b = a[[1,3,5]] # copy (fancy indexing) b = a[a > 0] # copy (boolean indexing) |
Exercise: Create array a → make 6 different b’s → change b[0] = 999 → check if a changed Do this for each case above
Phase 2 – Core Operations (12–25 hours)
5. Indexing & Slicing Mastery (4–7 h)
Must fluently read/write:
- basic indexing a[3, -1]
- slicing a[2:7:2], a[::-1]
- boolean indexing a[a > 50]
- fancy indexing a[[1,4,7], :]
- combined a[a[:,0] > 100, 2:5]
Exercise: Create 8×10 array → extract 7 different meaningful sub-arrays using different techniques
6. Arithmetic & Broadcasting – the heart of NumPy (4–8 h)
Must be automatic:
|
0 1 2 3 4 5 6 7 8 9 10 11 |
a + b a * 5 a ** 2 np.sin(a) a > 0 np.clip(a, 0, 100) |
- broadcasting rules (especially adding (m,1) + (1,n) → (m,n))
Exercise: Create 100×100 array where value[i,j] = sin(i/10) × cos(j/10) × 100 (without meshgrid or loops)
7. Reductions – sum, mean, prod, min, max, std, any, all (3–5 h)
Must know:
|
0 1 2 3 4 5 6 7 8 9 10 |
.sum(axis=0) # column sums .mean(axis=1) # row means .prod() # total product .cumsum(axis=1) # running sum per row .any(axis=0) # any True per column |
Exercise: Create 500×20 random array → compute:
- mean & std per column
- rows with sum > 500
- columns where all values are positive
8. Masking, np.where, filtering, replacing (3–5 h)
Must be fluent:
|
0 1 2 3 4 5 6 7 8 |
mask = arr > 50 arr[mask] = 0 arr = np.where(arr < 0, 0, arr) |
Exercise: Create array → replace negatives with 0, values > 100 with 100, values between 40–60 with their negative
Phase 3 – Intermediate & Practical Mastery (10–20 hours)
9. Reshape, ravel, flatten, transpose, swapaxes (2–4 h)
Must know the difference:
- .reshape(-1) vs .ravel() vs .flatten()
- view vs copy behavior
- .T vs .transpose()
Exercise: Flatten a 4D array in different ways → change one value → see which original array changed
10. Concatenation & splitting (2–4 h)
Must know:
|
0 1 2 3 4 5 6 7 8 9 |
np.concatenate([a,b], axis=0) np.vstack(), np.hstack(), np.dstack() np.split(arr, 3, axis=1) np.array_split(arr, 4) # uneven ok |
Exercise: Split 100×100 image into 4 quadrants Recombine them in rotated order
11. Random numbers & distributions (3–6 h)
Must know at least:
|
0 1 2 3 4 5 6 7 8 |
np.random.seed(42) np.random.rand / randn / randint / uniform / normal np.random.choice / shuffle / permutation |
Exercise: Simulate 10,000 coin flips → count heads Simulate 1000 students → scores ~ N(72, 12) → clip 0–100
12. Sorting, argsort, unique, unique rows (2–4 h)
Must know:
|
0 1 2 3 4 5 6 7 8 9 |
np.sort(arr, axis=0) np.argsort(arr)[:10] # top-10 indices np.unique(arr, return_counts=True) np.unique(arr, axis=0) # unique rows |
Exercise: Find 10 highest values + their original indices
Phase 4 – Real-world & Advanced Patterns (10–20 hours)
13. Masking + where + advanced filtering (3–5 h)
14. Log-transforms, clipping, normalization patterns (2–4 h)
15. Working with NaN – nansum, nanmean, nanstd, isnan (2–3 h)
16. Strided views & as_strided (advanced memory tricks) (3–6 h)
17. Vectorization patterns – when loops are still needed & how to avoid them (3–6 h)
18. Mini-projects to tie everything together (5–10 h)
- Clean & normalize messy dataset
- Simulate & visualize stock prices with returns & volatility
- Process small image (contrast, grayscale, edge detection)
- Create your own mini “Pandas-like” group-by with NumPy only
- Implement simple moving average / rolling stats vectorized
Suggested learning path (realistic timeline)
Week 1–2 → Phase 1 + Phase 2 (20–30 h) Week 3–4 → Phase 3 (10–20 h) Week 5–8 → Phase 4 + mini-projects (15–30 h)
Final teacher note
The real goal is not to “finish NumPy” The real goal is to reach the point where:
- You never write for-loops for element-wise operations
- You automatically think in terms of shapes & axes
- You instinctively reach for broadcasting & masking
- You feel faster and more confident than people who use only Python lists
Once you reach that point — NumPy stops being “a library” and becomes your natural way of thinking about numbers.
Which part would you like to start with? Or do you want me to expand any particular section with more exercises right now?
Tell me — I’m here to help you master this. 😊
