本文摘自php中文网,作者(*-*)浩,侵删。
sqrt() 方法返回数字x的平方根。

以下是 sqrt() 方法的语法:(推荐学习:Python视频教程)
1 2 3 | import math
math.sqrt( x )
|
注意:sqrt()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。
参数
x -- 数值表达式。
返回值
返回数字x的平方根。
实例
以下展示了使用 sqrt() 方法的实例:
1 2 3 4 5 6 | #!/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)
|
以上实例运行后输出结果为:
1 2 3 | math.sqrt(100) : 10.0
math.sqrt(7) : 2.64575131106
math.sqrt(math.pi) : 1.77245385091
|
更多Python相关技术文章,请访问Python教程栏目进行学习!
以上就是python中根号怎么表示的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python怎么调试程序
Python中re模块与正则表达式的介绍(附代码)
Python中5种连接字符串的方法
Python 的自省是什么?
什么是Python类属性?类的私有属性是什么?(实例解析)
什么是Python中唯一的映射类型
怎么获得一个字符串的子串
Python是一种什么类型的编程语言
Python在excel中的应用是什么
Python 怎么求平均值
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python中根号怎么表示