Python sqrt()返回x>0的x的平方根。
sqrt(x) - 语法
import mathmath.sqrt( x )
x - 这是一个数值表达式。
sqrt(x) - 返回值
此方法返回x>0的x的平方根。
sqrt(x) - 示例
以下示例显示sqrt()方法的用法。
#!/usr/bin/python import math # This will import math moduleprint "math.sqrt(100) : ", math.sqrt(100) print "math.sqrt(7) : ", math.sqrt(7) print "math.sqrt(math.pi) : ", math.sqrt(math.pi)
当无涯教程运行上面的程序时,它产生以下输出-
math.sqrt(100) : 10.0 math.sqrt(7) : 2.64575131106 math.sqrt(math.pi) : 1.77245385091