Python數位exp()方法

2019-10-16 23:06:57

Python數位exp()方法返回e指數x

語法

以下是exp()方法的語法 -

import math

math.exp( x )

注意 - 此方法不能直接存取,需要匯入math模組,然後使用math靜態物件呼叫此函式。

引數

  • x - 這是一個數位表示式。

返回值

  • 該方法返回指數x

範例

以下範例顯示了exp()方法的用法。

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

print ("math.exp(-45.17) : ", math.exp(-45.17))
print ("math.exp(100.12) : ", math.exp(100.12))
print ("math.exp(100.72) : ", math.exp(100.72))
print ("math.exp(math.pi) : ", math.exp(math.pi))

當執行上述程式時,它會產生以下結果 -

math.exp(-45.17) :  2.4150062132629406e-20
math.exp(100.12) :  3.0308436140742566e+43
math.exp(100.72) :  5.522557130248187e+43
math.exp(math.pi) :  23.140692632779267