Python sqrt()返回x>0的x的平方根。
import math math.sqrt( x )
x - 这是一个数值表达式。
此方法返回x>0的x的平方根。
以下示例显示sqrt()方法的用法。
#!/usr/bin/python import math # This will import math module print "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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)