Bird
0
0

You have two arrays:

hard📝 Application Q15 of 15
NumPy - Array Operations
You have two arrays:
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])

Which code correctly computes the element-wise product and then applies the square root to each product?
Anp.multiply(a, b) + np.sqrt(a)
Bnp.multiply(np.sqrt(a), np.sqrt(b))
Cnp.sqrt(a) * np.sqrt(b)
Dnp.sqrt(np.multiply(a, b))
Step-by-Step Solution
Solution:
  1. Step 1: Understand element-wise product and sqrt

    First multiply elements of a and b, then apply square root on the result.
  2. Step 2: Check each option

    np.sqrt(np.multiply(a, b)) does np.multiply(a, b) then np.sqrt(), which is correct. Options B and C apply sqrt before multiply, which is different. np.multiply(a, b) + np.sqrt(a) adds sqrt(a), which is incorrect.
  3. Final Answer:

    np.sqrt(np.multiply(a, b)) -> Option D
  4. Quick Check:

    Multiply then sqrt = np.sqrt(np.multiply(a,b)) [OK]
Quick Trick: Multiply first, then sqrt for correct order [OK]
Common Mistakes:
  • Applying sqrt before multiplication
  • Adding instead of multiplying
  • Mixing order of operations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes