Bird
0
0

What will be the dtype of the result after this operation?

medium📝 Predict Output Q5 of 15
NumPy - Array Operations
What will be the dtype of the result after this operation?
import numpy as np
arr1 = np.array([1+2j, 3+4j])
arr2 = np.array([1, 2])
result = arr1 * arr2
print(result.dtype)
Aint64
Bcomplex64
Cfloat64
Dcomplex128
Step-by-Step Solution
Solution:
  1. Step 1: Identify input dtypes

    arr1 is complex128 by default, arr2 is int64.
  2. Step 2: Apply type promotion rules

    Multiplying complex128 and int64 promotes to complex128.
  3. Final Answer:

    complex128 -> Option D
  4. Quick Check:

    complex128 * int64 = complex128 [OK]
Quick Trick: Complex with int promotes to complex128 [OK]
Common Mistakes:
  • Assuming complex64 result
  • Expecting float64 result
  • Ignoring complex promotion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes