# sine bug?

[code]>>> from math import sin
>>> for i in range(10):
print sin(i)

0.0
0.841470984808
0.909297426826
0.14112000806
-0.756802495308
-0.958924274663
-0.279415498199
0.656986598719
0.989358246623
0.412118485242
>>>[/code]

What the heck? Why are there negative numbers there? These are not the answers my calculator gives :-(

• Hah, this is silly. I looked at the doc string:

[code]>>> print sin.__doc__
sin(x)

Return the sine of x (measured in radians).
>>>[/code]

I was assuming degrees, silly me. I can now get what I wanted like this:

[code]>>> for i in range(10):

0.0
0.0174524064373
0.0348994967025
0.0523359562429
0.0697564737441
0.0871557427477
0.104528463268
0.121869343405
0.13917310096
0.15643446504
>>>[/code]
• : Hah, this is silly. I looked at the doc string:
:
: [code]>>> print sin.__doc__
: sin(x)
:
: Return the sine of x (measured in radians).
: >>>[/code]
:
: I was assuming degrees, silly me. I can now get what I wanted like this:
:
: [code]>>> for i in range(10):
:
:
: 0.0
: 0.0174524064373
: 0.0348994967025
: 0.0523359562429
: 0.0697564737441
: 0.0871557427477
: 0.104528463268
: 0.121869343405
: 0.13917310096
: 0.15643446504
: >>>[/code]

Very cool! And thanks for the demonstration of the __doc__ attribute.

[size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

• : : Hah, this is silly. I looked at the doc string:
: :
: : [code]>>> print sin.__doc__
: : sin(x)
: :
: : Return the sine of x (measured in radians).
: : >>>[/code]
: :
: : I was assuming degrees, silly me. I can now get what I wanted like this:
: :
: : [code]>>> for i in range(10):
: : print sin(radians(i))
: :
: :
: : 0.0
: : 0.0174524064373
: : 0.0348994967025
: : 0.0523359562429
: : 0.0697564737441
: : 0.0871557427477
: : 0.104528463268
: : 0.121869343405
: : 0.13917310096
: : 0.15643446504
: : >>>[/code]
:
: Very cool! And thanks for the demonstration of the __doc__ attribute.
:
:
: [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
:
:

Many times when I start a new python program I first remind myself
of method usages by doing the following method:
[code]def help(*args):
for arg in args:
print arg.__doc__
[/code]
And using it..

• : Many times when I start a new python program I first remind myself
: of method usages by doing the following method:
: [code]def help(*args):
: for arg in args:
: print arg.__doc__
: [/code]
: And using it..

Cool. Newer version of Python have a built-in help() function too.

[size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

• : : Many times when I start a new python program I first remind myself
: : of method usages by doing the following method:
: : [code]def help(*args):
: : for arg in args:
: : print arg.__doc__
: : [/code]
: : And using it..
:
: Cool. Newer version of Python have a built-in help() function too.
:
:
: [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
:
:

Yeah, I know, but I mostly use ActiveState Python 2.2.2 and PythonWin ide for "debugging" and so on and it doesn't have it.