Python cmath.sqrt() Method

❮ cmath Methods


Example

Find the square root of a complex number:

#Import cmath Library
import cmath

#Return the square root of a complex number
print (cmath.sqrt(2 + 3j))
print (cmath.sqrt(15))
Try it Yourself »

Definition and Usage

The cmath.sqrt() method returns the square root of a complex number.

Note: The number must be greater than or equal to 0.


Syntax

cmath.sqrt(x)

Parameter Values

Parameter Description
x Required. A number to find the square root of. If the number is less than 0, it returns a ValueError. If the value is not a number, it returns a TypeError

Technical Details

Return Value: A complex value, representing the square root of a complex number
Python Version: 1.5

❮ cmath Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.