Python math.acos() 方法
实例
返回不同数字的反余弦:
# Import math Libraryimport math# Return the arc cosine of numbersprint(math.acos(0.55))print(math.acos(-0.55))print(math.acos(0))print(math.acos(1))print(math.acos(-1))
定义与用法
math.acos() 方法返回数字的反余弦值。
注意:math.acos() 中传递的参数必须介于 -1 到 1 之间。
提示:math.acos(-1) 将返回 PI 的值。
语法
math.acos(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 必填。介于 -1 到 1 之间的数字。如果 x 不是一个数字,它将返回一个 TypeError |
技术细节
| 返回值: | 一个 float 值,表示数字的反余弦 |
|---|---|
| Python 版本: | 1.4 |