Bird
0
0

Why does numpy perform element-wise arithmetic by default instead of matrix operations?

hard📝 Conceptual Q10 of 15
NumPy - Array Operations
Why does numpy perform element-wise arithmetic by default instead of matrix operations?
ABoth C and D
BBecause numpy arrays are always 1D vectors.
CBecause matrix operations require special functions like np.dot or np.matmul.
DBecause element-wise operations are simpler and more intuitive for arrays.
Step-by-Step Solution
Solution:
  1. Step 1: Understand default numpy behavior

    Numpy arrays default to element-wise operations for simplicity and clarity.
  2. Step 2: Recognize matrix operations need special functions

    Matrix multiplication requires np.dot or np.matmul, not operators like *.
  3. Final Answer:

    Both C and D -> Option A
  4. Quick Check:

    Element-wise default + matrix needs special funcs = Both C and D [OK]
Quick Trick: Element-wise is default; matrix multiply needs np.dot or np.matmul [OK]
Common Mistakes:
  • Thinking * does matrix multiply
  • Assuming arrays are always 1D
  • Ignoring special matrix functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes