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
⌘⏎ run · ⌘← → nav
▶ Output
Run your code to see output here.