CKTIS / Python
math.sqrt
Berechnet die nichtnegative reelle Quadratwurzel als float.
Version: Python 3.14; repository image, production runtime not attested
Syntax
math.sqrt(x, /)Berechnet die nichtnegative reelle Quadratwurzel als float.
Wegen 9² = 81 lautet das Ergebnis 9,0. Die Wurzel von null ist 0,0.
Negative Argumente lösen ValueError aus, komplexe Wurzeln berechnet cmath.sqrt.
import math
assert math.sqrt(81) == 9.0 and type(math.sqrt(0)) is float
assert math.sqrt(0) == 0.0
Beispiele
import math
print(math.sqrt(81))
print(math.sqrt(0))
Ergebnis
9.0 0.0
Negative Argumente lösen ValueError aus, komplexe Wurzeln berechnet cmath.sqrt.