math.sin incorrect result

前端 未结 2 1769
南方客
南方客 2021-01-02 15:35
>>> import math
>>> math.sin(68)
-0.897927680689

But

sin(68) = 0.927 (3 decimal places)

Any ide

相关标签:
2条回答
  • 2021-01-02 16:09
    >>> import math
    >>> print math.sin.__doc__
    sin(x)
    
    Return the sine of x (measured in radians).
    

    math.sin expects its argument to be in radians, not degrees, so:

    >>> import math
    >>> print math.sin(math.radians(68))
    0.927183854567
    
    0 讨论(0)
  • 2021-01-02 16:11

    by default angle in Python is calculated in radians. So, you can try to multiply the angle ( degrees ) by 0.01745 - to convert it to degrees and input the values. print(math.sin(60*0.01745)) 0.8659266112878228

    0 讨论(0)
提交回复
热议问题