欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中利用sqrt()方法進行平方根計算的教程

 更新時間:2015年05月15日 10:38:04   投稿:goldensun  
這篇文章主要介紹了Python中利用sqrt()方法進行平方根計算的教程,是Python學(xué)習(xí)的基礎(chǔ)知識,需要的朋友可以參考下

 sqrt()方法返回x的平方根(x>0)。
語法

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

import math

math.sqrt( x )

注意:此函數(shù)是無法直接訪問的,所以我們需要導(dǎo)入math模塊,然后需要用math的靜態(tài)對象來調(diào)用這個函數(shù)。
參數(shù)

  •     x -- 這是一個數(shù)值表達(dá)式。

返回值

此方法返回x的平方根,對于x>0。
例子

下面的例子顯示了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)

當(dāng)我們運行上面的程序,它會產(chǎn)生以下結(jié)果:

math.sqrt(100) : 10.0
math.sqrt(7) : 2.64575131106
math.sqrt(math.pi) : 1.77245385091

相關(guān)文章

最新評論