现在位置: 首页 > Python 3 教程 > 正文

Python math.cosh() 方法

Python math 模块 Python math 模块

Python math.cosh(x) 返回 x 的双曲余弦值,相当于 (exp(number) + exp(-number)) / 2。

Python 版本: 1.4

语法

math.cosh() 方法语法如下:

math.cosh(x)

参数说明:

  • x -- 必需,个正数或负数。如果 x 不是一个数字,返回 TypeError。

返回值

返回一个浮点数,表示一个数字的双曲余弦值。

实例

以下实例返回不同数字的双曲余弦值:

实例

# 导入 math 包
import math

# 输出双曲余弦值
print (math.cosh(1))
print (math.cosh(8.90))
print (math.cosh(0))
print (math.cosh(1.52))

输出结果:

1.5430806348152437
3665.986837772461
1.0
2.395468541047187

Python math 模块 Python math 模块