ExampleEdit & Run
#import the cmath module
import cmath

#print the square root of a complex number
print(cmath.sqrt(-4))
Output:
2j[Finished in 0.010887018172070384s]

The cmath.sqrt() function computes the square root of a given complex number.

Syntax:
cmath.sqrt(x)
x The value(real or complex) whose square root is to be calculated. If the value is a real number, it is first converted to a complex number before the operation.
ExampleEdit & Run
import cmath

print(cmath.sqrt(-4))
print(cmath.sqrt(-16))
print(cmath.sqrt(7 + 3j))
print(cmath.sqrt(-3 + 4j))
print(cmath.sqrt(-7-2j))
Output:
2j4j(2.703310295347531+0.5548752588933427j)(1+2j)(0.3742391543388521-2.67208812441511j)[Finished in 0.010635020909830928s]