首页 > Python资料 博客日记
Python数字sqrt()方法
2023-08-04 15:52:25Python资料围观164次
这篇文章介绍了Python数字sqrt()方法,分享给大家做个参考,收藏Python资料网收获更多编程知识
Python数字sqrt()
函数返回x
的平方根(x > 0
)。
语法
以下是sqrt()
方法的语法 -
import math
math.sqrt( x )
注意 - 此函数不可直接访问,需要导入math
模块,然后需要使用math
静态对象调用此函数。
参数
x
- 这是一个数字表达式。
返回值
- 该方法返回
x
的平方根(x > 0
)。
示例
以下示例显示了sqrt()
方法的用法。
#!/usr/bin/python3
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.6457513110645907
math.sqrt(math.pi) : 1.7724538509055159
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签:
上一篇:Python 3D图
下一篇:Python列表pop()方法
相关文章
最新发布
点击排行
- 版本匹配指南:Numpy版本和Python版本的对应关系
- Python 可视化 web 神器:streamlit、Gradio、dash、nicegui;低代码 Python Web 框架:PyWebIO
- 版本匹配指南:PyTorch版本、torchvision 版本和Python版本的对应关系
- 相关性分析——Pearson相关系数+热力图(附data和Python完整代码)
- Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based proj
- Python pyinstaller打包exe最完整教程
- Anaconda版本和Python版本对应关系(持续更新...)
- Python与PyTorch的版本对应