CKTIS / Python
math.sqrt
Calcula la raíz cuadrada real no negativa como float.
Versión: Python 3.14; repository image, production runtime not attested
Sintaxis
math.sqrt(x, /)Calcula la raíz cuadrada real no negativa como float.
Puesto que 9² = 81, el resultado es 9,0. La raíz de cero vale 0,0.
Un argumento negativo provoca ValueError y cmath.sqrt calcula raíces complejas.
import math
assert math.sqrt(81) == 9.0 and type(math.sqrt(0)) is float
assert math.sqrt(0) == 0.0
Ejemplos
import math
print(math.sqrt(81))
print(math.sqrt(0))
Resultado
9.0 0.0
Un argumento negativo provoca ValueError y cmath.sqrt calcula raíces complejas.