Bird
0
0

The following code throws an error. What is the cause?

medium📝 Debug Q14 of 15
NumPy - Array Data Types
The following code throws an error. What is the cause?
import numpy as np
z = np.array([1+2j, 3+4j], dtype='complex64')
angle = np.angle(z, deg=True)
print(angle)
Anp.angle does not support degree output
BNo error; code runs fine
CMissing import for np.angle function
Ddtype 'complex64' is invalid for np.angle
Step-by-Step Solution
Solution:
  1. Step 1: Check dtype compatibility

    np.angle works with complex arrays of any valid complex dtype including complex64.
  2. Step 2: Check np.angle parameters

    The parameter deg=True is valid and returns angle in degrees.
  3. Final Answer:

    No error; code runs fine -> Option B
  4. Quick Check:

    np.angle supports complex64 and deg=True [OK]
Quick Trick: np.angle supports complex64 and degree output [OK]
Common Mistakes:
  • Assuming complex64 is unsupported by np.angle
  • Thinking deg=True is invalid
  • Expecting import error for np.angle

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes