[Tutor] Over-riding radians as default for trig calculations

Steven D'Aprano steve at pearwood.info
Sun Feb 28 23:47:32 CET 2010


On Mon, 1 Mar 2010 06:39:10 am AG wrote:
> After importing the math module and running
>
> math.cos( x )
>
> the result is in radians.

It certainly is not. The *result* of cos is a unitless number, not an 
angle.

What you mean is that the *input* to cos, x, has to be supplied in 
radians. No, you can't change that anywhere, but you can do this:

>>> math.cos(math.radians(45))
0.70710678118654757

So of course you can write your own function:

def cos(x):
    return math.cos(math.radians(x))

and call that.



-- 
Steven D'Aprano


More information about the Tutor mailing list