Python math.exp() 方法
math.exp() 方法是 math 模块的库方法,用于获取 index 形式的数字,它接受一个数字并以 index 格式返回数字(如果数字是x
,它返回e**x
。
注意:如果传递除数字以外的任何内容,该方法将返回类型错误,“TypeError:a float is required”。
math.exp() 方法的语法:
math.exp(n)
参数: n
– 整数或浮点数。
返回值: float
– 它返回一个浮点值,它是数字的 index 形式n
。
例:
Input:
a = 111.111
# function call
print(math.exp(a))
Output:
1.7984326512709283e+48
用于演示 math.exp() 方法示例的 Python 代码
# Python code demonstrate example of
# math.exp() method
import math
# numbers
a = 0
b = 245
c = -102.34
d = 111.111
e = -123.456
# printing values in exp format
print("exp(a):", math.exp(a))
print("exp(b):", math.exp(b))
print("exp(c):", math.exp(c))
print("exp(d):", math.exp(d))
print("exp(e):", math.exp(e))
输出
exp(a): 1.0 exp(b): 2.5243412626998188e+106 exp(c): 3.583461328080821e-45 exp(d): 1.7984326512709283e+48 exp(e): 2.4195825412645934e-54
相关用法
- Python math.cos()用法及代码示例
- Python math.cosh()用法及代码示例
- Python math.acosh()用法及代码示例
- Python math.fmod()用法及代码示例
- Python math.fsum()用法及代码示例
- Python math.remainder()用法及代码示例
- Python math.asinh()用法及代码示例
- Python math.atanh()用法及代码示例
- Python math.fabs()用法及代码示例
- Python math.log1p()用法及代码示例
- Python math.gcd()用法及代码示例
- Python math.frexp()用法及代码示例
- Python math.isqrt()用法及代码示例
- Python math.ldexp()用法及代码示例
- Python math.acos()用法及代码示例
- Python math.sin()用法及代码示例
- Python math.sqrt()用法及代码示例
- Python math.asin()用法及代码示例
- Python math.dist()用法及代码示例
- Python math.hypot()用法及代码示例
注:本文由纯净天空筛选整理自 math.exp() method with example in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。