Bird
0
0

What does it mean if two arrays are NOT compatible for broadcasting in NumPy?

easy📝 Conceptual Q2 of 15
NumPy - Broadcasting
What does it mean if two arrays are NOT compatible for broadcasting in NumPy?
AThey have the same number of dimensions
BAt least one dimension size differs and neither is 1
CThey have the same shape
DThey contain different data types
Step-by-Step Solution
Solution:
  1. Step 1: Understand broadcasting rules

    Two dimensions are compatible if they are equal or one is 1.
  2. Step 2: Identify incompatibility condition

    If any dimension differs and neither is 1, arrays cannot broadcast.
  3. Final Answer:

    At least one dimension size differs and neither is 1 means no broadcasting -> Option B
  4. Quick Check:

    Broadcasting incompatibility = B [OK]
Quick Trick: Dimension mismatch without 1 means no broadcasting [OK]
Common Mistakes:
  • Thinking same number of dimensions guarantees compatibility
  • Confusing data type with broadcasting rules
  • Assuming shape equality is required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes