python newbie
Hi,
I wanted to try some things with python and installed them on my system. The tutorial went well, but as I wanted to do some math things I get failures. For example I want to use pi (dump example, but anyway): Code:
import math Code:
Traceback (most recent call last): |
Check the constant's name is correct. Usually it'd be something like math.PI or whatever.
|
yeah,
math.pi did it. Thanks alot:) Another problem with the same background. When I want to use a function of math i.e. acos() and I use it the old way: Code:
acos(45) but when I try: Code:
math.acos(45) Code:
Traceback (most recent call last): |
What's your complete code? Eg.
Code:
import math |
acos == arccos ( i.e. cos inverse )
since cos doesnt' take any values above 1 and below -1 its giving that error.. may be you want to use cos function to find out the cos value for a given angle. and the angle has to be in radians most probably. hope this helps |
I have no code yet, I am only learning at the moment but your code is what I had in mind. But I get a failure:
Code:
>>> import math |
Oh somebody was faster than I,
yeah, okay I was mathematically wrong. math.acos(0.5) i.e. works. Thanks to you all. You helped me very much to get a foot in python. |
actually u can check a module member by using python prompt.
step is as follow python #open a prompt import math # import math module dir(math) # list math member |
All times are GMT -5. The time now is 05:16 PM. |