ExampleEdit & Run
#import the cmath module
import cmath

print(cmath.rect(1.0, 0.0))
copy
Output:
(1+0j) [Finished in 0.011155246756970882s]

The cmath.rect() function converts a complex number from polar coordinates(modulus and phase/angle) to rectangular coordinates(real and imaginary parts).

Syntax:
cmath.rect(r, phi)
copy
r The modulus, required.
phi The phase angle, required.

The function returns a complex number whose polar coordinates are (r, phi).

ExampleEdit & Run
import cmath

print(cmath.rect(2, 3))
print(cmath.rect(1, 2))
print(cmath.rect(0, 1))
print(cmath.rect(0.5, -2))
copy
Output:
(-1.9799849932008908+0.2822400161197344j) (-0.4161468365471424+0.9092974268256817j) 0j (-0.2080734182735712-0.45464871341284085j) [Finished in 0.010511908680200577s]