Decimal#exp():exp()是一個Decimal類方法,該方法以給定的數字返回(自然)指數函數e ** x的值
用法:Decimal.exp()
參數:十進製值
返回:給定數字的(自然)指數函數e ** x的值
代碼1:exp()方法示例
# Python Program explaining
# exp() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal(-1)
b = Decimal('0.142857')
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.exp() method
print ("\n\nDecimal a with exp() method : ", a.exp())
print ("Decimal b with exp() method : ", b.exp())
輸出:
Decimal value a : -1 Decimal value b : 0.142857 Decimal a with exp() method : 0.3678794411714423215955237702 Decimal b with exp() method : 1.153564830100120253802476512
代碼2:exp()方法的示例
# Python Program explaining
# exp() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal('-3.14')
b = Decimal('7.555')
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.exp() method
print ("\n\nDecimal a with exp() method : ", a.exp())
print ("Decimal b with exp() method : ", b.exp())
輸出:
Decimal value a : -3.14 Decimal value b : 7.555 Decimal a with exp() method : 0.04328279790196590079772976615 Decimal b with exp() method : 1910.270243928773816178935745
相關用法
- Python Decimal ln()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python Decimal as_integer_ratio()用法及代碼示例
- Python Decimal scaleb()用法及代碼示例
- Python Decimal shift()用法及代碼示例
- Python Decimal logical_and()用法及代碼示例
- Python Decimal as_tuple()用法及代碼示例
- Python Decimal is_qnan()用法及代碼示例
- Python Decimal logical_or()用法及代碼示例
- Python Decimal to_eng_string()用法及代碼示例
- Python Decimal to_integral_exact()用法及代碼示例
- Python Decimal sqrt()用法及代碼示例
- Python Decimal compare_signal()用法及代碼示例
- Python Decimal to_integral()用法及代碼示例
注:本文由純淨天空篩選整理自noobestars101大神的英文原創作品 Python | Decimal exp() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。