[Tutor] trigonometry in python

alan.gauld@bt.com alan.gauld@bt.com
Fri Nov 1 16:49:02 2002


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C281F0.11DBD930
Content-Type: text/plain;
	charset="iso-8859-1"

 >  when i import math module to count the value of for example sin(30), why
the value is not 0.5 ?  
 
Pytho, in common with most programming languages uses radians for the 
angle not degrees. To convert degrees to radians multiply by pi/180
 
So 30 degrees = pi/6 radians.
 
The constant value of pi can be found in the math module:
 
import math
angle = (30 * math.PI)/180
print math.sin(angle)
 
Alan G

------_=_NextPart_001_01C281F0.11DBD930
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>&nbsp;&gt; &nbsp;</FONT></SPAN>when i import math module to count the 
value of for example sin(30), why the value is not 0.5 ?&nbsp;<SPAN 
class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>Pytho, in common with most programming languages uses radians for the 
</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>angle not degrees. To convert degrees to radians&nbsp;multiply by 
pi/180</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>So 30 degrees = pi/6 radians.</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>The constant value&nbsp;of pi can be found in the math 
module:</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>import math</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>angle = (30 * math.PI)/180</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>print math.sin(angle)</FONT></SPAN></DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=350394521-01112002><FONT face="Courier New" color=#0000ff 
size=2>Alan G</FONT></SPAN></DIV></BODY></HTML>

------_=_NextPart_001_01C281F0.11DBD930--