Cube Roots

Roy Smith roy at panix.com
Thu Jan 2 15:06:09 EST 2003


John Smith <someone at microsoft.com> wrote:
> How does one take a root higher than square roots in Python?  Can I take the
> cube root of a number?

Same way you would in almost any language.  The Nth root of a number
is the number to the 1/Nth power, so:

import math
math.pow (x, 1.0/y)

or, if you wanted to be somewhat silly, math.pow (x, math.pow (y, -1))
:-)





More information about the Python-list mailing list