Reputation: 41
I think I have a buggy version of python, because I am getting the wrong result. If you type this: sin(degrees(39))*41/28 directly into google, you will get the value 0.92150485832. This is the correct value for the given equation.
When I try to execute this in python however, I get the value -1.11258224646.
The code I used:
number= float(sin(degrees(39))*41/28)
print number
I also tried the following code (removed degrees surrounding the 39), which returns the value 1.41127181563.
number= float(sin(39)*41/28)
print number
Just for the kicks, I also tried the code like this:
number= float(sin(radians(39))*41/28)
print number
This code returned the answer 0.921504858323, which would be the correct answer for the first equation
That shouldn't be possible as 39 in radians is 0.680678408. And using that number in the equation: (sin(0.680678408)*41)/28 we get 0.017395421, not 0.921504858323.
Can someone please explain what's going on here. I'm lost here.
Upvotes: 3
Views: 2010
Reputation: 3176
Use this
>> math.sin(math.radians(39))*41/28
0.9215048583229761
Upvotes: 0
Reputation: 1405
The explanation is in difference of interpretation of words "degrees" and "radians" between google and python.
In python these 2 are functions for converting from one unit to another:
To evaluate "float(sin(radians(39))*41/28)" statement python converts 39 degrees angle into radians (0.680678) then computing sin(x) which returns the sine of x radians, so we will get sin(39 degree)*41/28.
Upvotes: 3