Python3 exp()函式

2019-10-16 23:11:52
exp()方法返回x的指數冪: ex

語法

以下是 exp() 方法的語法:
import math

math.exp( x )

註:此函式無法直接存取,所以我們需要匯入 math 模組,然後用數學靜態物件呼叫這個函式。

引數

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

返回值

這個方法返回x的指數冪: ex.

範例

下面的範例顯示 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