#import the cmath module
import cmath
print(cmath.rect(1.0, 0.0))
The cmath.rect()
function converts a complex number from polar coordinates(modulus and phase/angle) to rectangular coordinates(real and imaginary parts).
cmath.rect(r, phi)
r |
The modulus, required. |
phi |
The phase angle, required. |
The function returns a complex number whose polar coordinates are (r, phi)
.
import cmath
print(cmath.rect(2, 3))
print(cmath.rect(1, 2))
print(cmath.rect(0, 1))
print(cmath.rect(0.5, -2))