當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python 3 Number exp()用法及代碼示例


描述

這個exp()方法返回 x:e 的 index x

用法

以下是語法exp()方法 -

import math

math.exp( x )

注意− 此函數不可直接訪問。因此,我們需要導入 math 模塊,然後我們需要使用 math 靜態對象調用這個函數。

參數

x- 這是一個數字表達式。

返回值

此方法返回 x:e 的 index 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

相關用法


注:本文由純淨天空篩選整理自 Python 3 - Number exp() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。