CKTIS / Python
math.sqrt
Berekent de niet-negatieve reële vierkantswortel als float.
Versie: Python 3.14; repository image, production runtime not attested
Syntax
math.sqrt(x, /)Berekent de niet-negatieve reële vierkantswortel als float.
Omdat 9² = 81 is de uitkomst 9,0. De wortel van nul is 0,0.
Een negatief argument veroorzaakt ValueError en cmath.sqrt berekent complexe wortels.
import math
assert math.sqrt(81) == 9.0 and type(math.sqrt(0)) is float
assert math.sqrt(0) == 0.0
Voorbeelden
import math
print(math.sqrt(81))
print(math.sqrt(0))
Resultaat
9.0 0.0
Een negatief argument veroorzaakt ValueError en cmath.sqrt berekent complexe wortels.