Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
NumPy - Array Operations
What is wrong with this code?
import numpy as np
arr = np.array([1, 2, 3])
result = np.power(arr)
print(result)
Anp.array is not defined
Bnp.power requires two arguments, base and exponent
Cnp.power cannot be used with arrays
Dprint function is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Review np.power function usage

    np.power needs two arguments: base and exponent.
  2. Step 2: Check code arguments

    Only one argument (arr) is given, so it will cause an error.
  3. Final Answer:

    np.power requires two arguments, base and exponent -> Option B
  4. Quick Check:

    np.power needs base and exponent [OK]
Quick Trick: np.power(base, exponent) needs two inputs [OK]
Common Mistakes:
  • Passing single argument to np.power
  • Confusing np.power with np.sqrt
  • Ignoring function argument requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes