• 技术文章 >后端开发 >Python教程

    python中sqrt是什么意思

    藏色散人藏色散人2019-06-24 10:37:56原创16956

    python中sqrt是什么意思?

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

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

    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中sqrt是什么意思的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:python sqrt
    上一篇:python中str和repr有什么区别 下一篇:爬虫为什么用python
    20期PHP线上班

    相关文章推荐

    • 【活动】充值PHP中文网VIP即送云服务器• python注释怎么写• python中#是什么意思• python中的str是什么意思• python中str和repr有什么区别
    1/1

    PHP中文网