Python3 log() 函數(shù)

Python3 數(shù)字 Python3 數(shù)字


描述

log() 方法返回x的自然對(duì)數(shù),x > 0。


語(yǔ)法

以下是 log() 方法的語(yǔ)法:

import math

math.log( x )

注意:log()是不能直接訪問(wèn)的,需要導(dǎo)入 math 模塊,通過(guò)靜態(tài)對(duì)象調(diào)用該方法。


參數(shù)

  • x -- 數(shù)值表達(dá)式。

返回值

返回x的自然對(duì)數(shù),x>0。

實(shí)例

以下展示了使用 log() 方法的實(shí)例:

#!/usr/bin/python3
import math   # 導(dǎo)入 math 模塊

print ("math.log(100.12) : ", math.log(100.12))
print ("math.log(100.72) : ", math.log(100.72))
print ("math.log(math.pi) : ", math.log(math.pi))

以上實(shí)例運(yùn)行后輸出結(jié)果為:

math.log(100.12) :  4.6063694665635735
math.log(100.72) :  4.612344389736092
math.log(math.pi) :  1.1447298858494002

Python3 數(shù)字 Python3 數(shù)字