亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

介紹Python中的fabs()方法的使用

 更新時間:2015年05月14日 17:28:02   投稿:goldensun  
這篇文章主要介紹了介紹Python中的fabs()方法的使用,是Python入門當中的基礎(chǔ)知識,需要的朋友可以參考下

 方法fabs()返回 x 的絕對值。
語法

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

import math

math.fabs( x )

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

  •     x -- 這是一個數(shù)值。

返回值

此方法返回 x 的絕對值。
例子

下面的例子顯示fabs()方法的使用。

#!/usr/bin/python
import math  # This will import math module

print "math.fabs(-45.17) : ", math.fabs(-45.17)
print "math.fabs(100.12) : ", math.fabs(100.12)
print "math.fabs(100.72) : ", math.fabs(100.72)
print "math.fabs(119L) : ", math.fabs(119L)
print "math.fabs(math.pi) : ", math.fabs(math.pi)

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

math.fabs(-45.17) : 45.17
math.fabs(100.12) : 100.12
math.fabs(100.72) : 100.72
math.fabs(119L) : 119.0
math.fabs(math.pi) : 3.14159265359


相關(guān)文章

最新評論