math.cos(x) not returning correct value?
<p>I just started using python, and am having difficulty with a very basic program. I want to calculate the cosine of -20 degrees. It is my understanding that the default value is in radians, so this is the following code i tried:</p>

<pre><code>import math 


print math.cos(math.degrees(-20))
</code></pre>

<p>This outputs (-.7208...), where the answer is actually (.9397...). I'm sure this has a pretty basic solution but I've tried so many different things and it will not output the correct results. Thanks in advance!</p>

<p><code>math.degrees</code> takes a number of radians and <em>produces</em> a number of degrees. You need the opposite conversion - you have a number of degrees, and you need to produce a number of radians you can pass to <code>math.cos</code>. You need <code>math.radians</code>:</p>

<pre><code>math.cos(math.radians(-20))
</code></pre>

python math trigonometry