Python3 exp()函数

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

上一篇: Python3循环 下一篇: Python3数字