#import the cmath module
import cmath
#print the square root of a complex number
print(cmath.sqrt(-4))
The cmath.sqrt()
function computes the square root of a given complex number.
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. |
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))