Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
NumPy - Array Data Types
What will be the output of this code?
import numpy as np
z = np.array([1+2j, 3+4j], dtype=np.complex128)
print(z[1].real)
A1.0
B3.0
C4.0
D2.0
Step-by-Step Solution
Solution:
  1. Step 1: Access second element of array

    z[1] is the second complex number: 3+4j.
  2. Step 2: Extract real part

    The real part of 3+4j is 3.0.
  3. Final Answer:

    3.0 -> Option B
  4. Quick Check:

    Real part of z[1] = 3.0 [OK]
Quick Trick: Use .real to get real part of complex number [OK]
Common Mistakes:
  • Using imaginary part instead
  • Accessing wrong index
  • Confusing real and imaginary parts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes