>>> import math >>> math.sin(68) -0.897927680689
But
sin(68) = 0.927 (3 decimal places)
Any ideas on why I am getting this result?Thanks.
>>> 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
This is because you use degrees and trigonometric functions expect radians as input: sin (radians)Description for sin: sin(x) Return the sine of x (measured in radians). In Python, you can convert degrees to radians using the math.radians function.So, if you do this with your input: >>> math.sin(math.radians(35)) * 15 + 9 17.60364654526569 it gives the same result as your calculator.
This is because you use degrees and trigonometric functions expect radians as input: sin (radians)
Description for sin:
sin(x) Return the sine of x (measured in radians).
In Python, you can convert degrees to radians using the math.radians function.
So, if you do this with your input:
>>> math.sin(math.radians(35)) * 15 + 9 17.60364654526569
it gives the same result as your calculator.
So itโs true, itโs true that โ math.sin the wrong result โ is incorrect,math.sin result math.sin correct , but just used in another format / style (radians) to enter the one you want to use (in degrees).
math.sin
Therefore, you just need to convert radians to degrees inmake the result as you want (maybe like your calculator).