不正常的数学结果不正确?

Rip*_*ace 2 python math trigonometry

当我使用math.cos()和math.sin()函数时,我的python解释器表现得很时髦.例如,如果我在计算器上执行此操作:

cos(35)*15+9 = 21.28728066
sin(35)*15+9 = 17.60364655
Run Code Online (Sandbox Code Playgroud)

但是当我在python上执行此操作时(3.2和2.7)

>>> import math
>>> math.cos(35)*15+9
-4.5553830763726015

>>> import math
>>> math.sin(35)*15+9
2.577259957557734
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

编辑:为了以防万一,你如何将Python中的Radian更改为度?

nye*_*e17 9

这是由于您使用
和三角函数期望弧度作为输入这一事实引起的:
sin(radians)

描述sin是:

sin(x)
    Return the sine of x (measured in radians).
Run Code Online (Sandbox Code Playgroud)

在Python中,您可以使用该math.radians函数将度数转换为弧度.


因此,如果您使用输入执行此操作:

>>> math.sin(math.radians(35)) * 15 + 9
17.60364654526569
Run Code Online (Sandbox Code Playgroud)

它给出了与计算器相同的结果.