Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
math.pow() problem
-
I have a question with the math.pow() function. I was attempting to take the <i>n</i>th root of a number, and there is no function to take roots other than 'sqrt()'. So I tried to use fractional exponents, since 4^(1/2) is the same as taking the square root of 4. I tested this theory in the interpreter, but this is what happened:
>>>pow(2, (1/2))
1.0
>>>pow(4, (1/2))
1.0
As you can see, the app is telling me that 2^(1/2) and 4^(1/2) are both equal to 1, which is true of neither. My question is, how do I take <i>n</i>th roots of a number?
Thank you!*sorry for the bad formatting, Im new at this
-
Ohh darn this is in the wrong place. I just saw the 'Pythonista' category underneath 'Editorial'....anyone know how to move posts?
-
The problem is that
1/2
evaluates to0
because you're dividing two integers, if you use1.0/2.0
instead, you should get the expected result (1./2
is actually enough).