-->

math.sin incorrect result

2019-03-27 11:13发布

问题:

>>> import math
>>> math.sin(68)
-0.897927680689

But

sin(68) = 0.927 (3 decimal places)

Any ideas about why I am getting this result?
Thanks.

回答1:

>>> 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