目录

python怎么用根号_python中根号怎么表示

目录

python怎么用根号_python中根号怎么表示

sqrt() 方法返回数字x的平方根。

https://i-blog.csdnimg.cn/blog_migrate/2db0bda636b5031d75dd53f60fa9fba9.jpeg

以下是 sqrt() 方法的语法:(推荐学习:Python视频教程)import math

math.sqrt( x )

注意:sqrt()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。

参数

x – 数值表达式。

返回值

返回数字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

更多Python相关技术文章,请访问Python教程栏目进行学习!

以上就是python中根号怎么表示的详细内容,更多请关注雅婷课堂其它相关文章!