python math.cos()方法,求余弦

math.cos()方法

python math module模块的cos()方法,可求取弧度制参数的余弦值。将角度制参数改成弧度制,可参考如下python代码,其中x表示角度值:

x*math.pi / 180

cos()语法

cos(x, /)

python源码对于cos()的介绍,其中measured in radians表示用弧度制来衡量x:

    Return the cosine of x (measured in radians).

cos()参数

参数描述
x弧度制测量的角度值。

cos()返回值

参数的余弦值,python float类型。


cos()实例代码

下方的实例代码求取60°角经转化为弧度制值后的余弦值:

>>> import math
>>> math.cos(math.pi / 3)
0.5000000000000001

全栈后端 / Python库 :









Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.