python培训之sqrt啥意思

发布时间:2022-10-18 09:50:41 人气:136 作者:多测师

  python中有很多的内置函数,这些函数能实现特定的功能,而不需要重新定义函数。下面看一个math模块中的sqrt()函数。

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

  以下是 sqrt() 方法的语法:

  import math

  math.sqrt( x )

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

python培训之sqrt啥意思

  参数,x -- 数值表达式。

  返回值,返回数字x的平方根。

  实例

  #!/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培训之sqrt啥意思,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注多测师。https://www.e70w.com/xwzx/


返回列表
在线客服
联系方式

热线电话

17727591462

上班时间

周一到周五

二维码
线