Python cmath.sqrt() Methode
Voorbeeld
Zoek de vierkantswortel van een complex getal:
#Import cmath Library
import cmath
#Return the square root of a
complex number
print (cmath.sqrt(2 + 3j))
print (cmath.sqrt(15))
Definitie en gebruik
De cmath.sqrt()
methode retourneert de vierkantswortel van een complex getal.
Opmerking: het getal moet groter dan of gelijk zijn aan 0.
Syntaxis
cmath.sqrt(x)
Parameterwaarden
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 |
Technische details
Winstwaarde: | Een complex waarde die de vierkantswortel van een complex getal weergeeft |
---|---|
Python-versie: | 1.5 |