sine in python

Carl Banks pavlovevidence at gmail.com
Sun Apr 6 22:23:20 EDT 2008


On Apr 6, 5:10 pm, Mark Wooding <m... at distorted.org.uk> wrote:
> Astan Chee <st... at al.com.au> wrote:
> > I have a math function that looks like this
> > sin (Theta) = 5/6
> > How do I find Theta (in degrees) in python?
>
> import math
> theta = math.asin(5/6) * 180/math.pi


Careful there, bud.  5/6 might not give you the value you're expecting
it to, depending on the version of Python you're using.  If you're on
Python 2.x, you'll want to use "from __future__ import division", or
to specify 5 and 6 as floats, i.e., 5.0/6.0.

(And people claim 5/6 == 0 is the "obvious" result....)


Carl Banks



More information about the Python-list mailing list