python中sqrt是什么意思
生活随笔
收集整理的這篇文章主要介紹了
python中sqrt是什么意思
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
本篇文章為大家展示了python中sqrt是什么意思,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
python中有很多的內(nèi)置函數(shù),這些函數(shù)能實(shí)現(xiàn)特定的功能,而不需要重新定義函數(shù)。下面看一個(gè)math模塊中的sqrt()函數(shù)。
sqrt() 方法返回?cái)?shù)字x的平方根。
以下是 sqrt() 方法的語(yǔ)法:
importmath math.sqrt(x)
注意:sqrt()是不能直接訪問(wèn)的,需要導(dǎo)入 math 模塊,通過(guò)靜態(tài)對(duì)象調(diào)用該方法。
參數(shù),x -- 數(shù)值表達(dá)式。
返回值,返回?cái)?shù)字x的平方根。
實(shí)例
#!/usr/bin/python importmath#Thiswillimportmathmodule print"math.sqrt(100):",math.sqrt(100) print"math.sqrt(7):",math.sqrt(7) print"math.sqrt(math.pi):",math.sqrt(math.pi)
返回結(jié)果
math.sqrt(100):10.0 math.sqrt(7):2.64575131106 math.sqrt(math.pi):1.77245385091
總結(jié)
以上是生活随笔為你收集整理的python中sqrt是什么意思的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java在线用户查看_java Sess
- 下一篇: 数据库系统的组成部分是什么