math.sin incorrect result

前端 未结 2 1788
南方客
南方客 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
    

提交回复
热议问题