Find the real and imaginary parts of an array of complex numbers using NumPy.

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
  1. Import the numpy library as np.
  2. Create an array of complex numbers using np.array().
  3. Find the real and imaginary parts of an array of complex numbers using real and imag.
  4. 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.]
				
			

add a row of a matrix into another row.

find common elements between two arrays.

Leave a Comment