0 / 34
Lesson 14

Broadcasting Basics

Broadcasting handles different-shaped arrays:

a * 10  # scalar broadcast
m + v   # 1D broadcasts over 2D rows

Rules

  • Compare dims right to left
  • Sizes match OR one is 1
Why this matters

Broadcasting is why you can write matrix * vector without nested loopsβ€”it is the mental model behind most β€œit just works” shape math in NumPy.

Shape mistakes here show up everywhere: normalization, biases in neural nets, feature scaling.

ResourcesDocs, references & more β€” opens in a new tab
🎯 Your Task

prices = [[10,20,30],[40,50,60]], tax_rate = [0.05,0.08,0.10]. Compute totals = prices + prices * tax_rate.

tax_rate broadcasts across rows
exercise.py
⌘⏎ run Β· βŒ˜β† β†’ nav
β–Ά Output
Run your code to see output here.