NumPy - BroadcastingWhy does NumPy allow broadcasting when one dimension is 1 but not when dimensions differ and neither is 1?ABecause arrays with different sizes cannot be used togetherBBecause dimensions must always be equal for operationsCBecause broadcasting only works for 1D arraysDBecause dimension 1 can be stretched to match the other dimension without copying dataCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand broadcasting mechanicsDimension size 1 can be virtually repeated to match the other dimension without extra memory.Step 2: Contrast with incompatible dimensionsIf neither dimension is 1 and sizes differ, no safe broadcasting is possible.Final Answer:Because dimension 1 can be stretched to match the other dimension without copying data -> Option DQuick Check:Dimension 1 allows virtual stretching [OK]Quick Trick: Dimension 1 stretches without copying [OK]Common Mistakes:Thinking all different sizes broadcastAssuming broadcasting copies dataBelieving broadcasting is only for 1D arrays
Master "Broadcasting" in NumPy9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More NumPy Quizzes Aggregation Functions - np.sum() and axis parameter - Quiz 7medium Array Data Types - Complex number type - Quiz 2easy Array Manipulation - np.concatenate() for joining arrays - Quiz 5medium Array Manipulation - reshape() for changing dimensions - Quiz 6medium Array Operations - Why vectorized operations matter - Quiz 6medium Creating Arrays - np.zeros() for zero-filled arrays - Quiz 8hard NumPy Fundamentals - NumPy and scientific computing ecosystem - Quiz 10hard NumPy Fundamentals - Installing and importing NumPy - Quiz 6medium NumPy Fundamentals - Why NumPy over Python lists - Quiz 5medium NumPy Fundamentals - Contiguous memory layout concept - Quiz 5medium