Bird
0
0

You have arrays with shapes (7, 1, 5) and (1, 3, 1). You want to add them using broadcasting. What will be the resulting shape?

hard📝 Application Q15 of 15
NumPy - Broadcasting
You have arrays with shapes (7, 1, 5) and (1, 3, 1). You want to add them using broadcasting. What will be the resulting shape?
A(1, 3, 5)
B(7, 1, 1)
C(7, 3, 5)
DCannot broadcast these shapes
Step-by-Step Solution
Solution:
  1. Step 1: Compare shapes from right to left

    Right dims: 5 and 1, 1 broadcasts to 5. Middle dims: 1 and 3, 1 broadcasts to 3. Left dims: 7 and 1, 1 broadcasts to 7.
  2. Step 2: Combine broadcasted dimensions

    Resulting shape is (7, 3, 5) taking max of each dimension.
  3. Final Answer:

    (7, 3, 5) -> Option C
  4. Quick Check:

    Broadcast dims max or 1 expands [OK]
Quick Trick: Broadcast dims max or 1 expands to max [OK]
Common Mistakes:
  • Mixing up dimension order
  • Assuming shapes must be identical
  • Forgetting 1 can broadcast to any size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes