在python中使用abs()函數求絕對值的方法
abs:abs()函數的作用是返回一個數字的絕對值。
abs()函數語法:
abs( x )
abs()函數使用方法:
print ("abs(-40) : ", abs(-40))print ("abs(100.10) : ", abs(100.10))
print ("abs(-40) : ", abs(-40))
print ("abs(100.10) : ", abs(100.10))
輸出結果為:
abs(-40) : 40abs(100.10) : 100.1
abs(-40) : 40
abs(100.10) : 100.1