Q:

Write a NumPy program to find the real and imaginary parts of an array of complex numbers

0

Write a NumPy program to find the real and imaginary parts of an array of complex numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.sqrt([1+0j])
y = np.sqrt([0+1j])
print("Original array:x ",x)
print("Original array:y ",y)
print("Real part of the array:")
print(x.real)
print(y.real)
print("Imaginary part of the array:")
print(x.imag)
print(y.imag)

Sample Output:

Original array:x  [ 1.+0.j]
Original array:y  [ 0.70710678+0.70710678j]
Real part of the array:
[ 1.]
[ 0.70710678]
Imaginary part of the array:
[ 0.]
[ 0.70710678]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now