In this python numpy program, we will find the real and imaginary parts of an array of complex numbers using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array of complex numbers using np.array().
- Find the real and imaginary parts of an array of complex numbers using real and imag.
- Print the output.
import numpy as np
x = np.array([6+2j,10+5j])
print("Real part: ",x.real)
print("Imaginary part: ",x.imag)
Output :
Real part: [ 6. 10.]
Imaginary part: [2. 5.]