04-01: NumPy Array Explorer¶
Six interactive demonstrations of NumPy fundamentals: array creation, vectorised arithmetic (BDT→USD pricing), slicing/boolean indexing, statistical functions, reshape/broadcasting, and random number generation.
Topics covered: np.array() · np.arange() · np.linspace() · vectorised ops · boolean indexing · np.mean/median/std · reshape() · broadcasting · np.random
Difficulty: ⭐⭐ Intermediate
Requirements¶
How to Run¶
Sample Output (Demo 2 — Vectorised Arithmetic)¶
BDT prices : [ 110 550 220 880 1320]
USD prices : [ 1. 5. 2. 8. 12. ]
a + b = [11 22 33 44]
b ** 2 = [100 400 900 1600]
Key Concepts Practised¶
| Concept | Where used |
|---|---|
np.arange(start, stop, step) |
demo_creation() |
array / scalar (vectorised) |
BDT→USD conversion |
arr[arr > 30] (boolean indexing) |
demo_slicing() |
matrix[:, 2] (column select) |
2D indexing |
flat.reshape(3, 4) |
demo_reshape() |
matrix + row_bonus (broadcast) |
Broadcasting rules |
np.random.seed(42) |
Reproducible results |