[Tutor] How do I do cubic roots and cubic exponents (and higherroots and exponents) in Python?
Alan Gauld
alan.gauld at freenet.co.uk
Wed May 10 22:01:04 CEST 2006
> How do I do cubic (and higher) roots and exponents in Python? I
> already took
> a look in Python and didn't find anything.
The nth root is just the number raised to the power of 1/n
x = 27
n = 3
exp = 1/n
cube_root = x**exp
or if you prefer:
def root(number, n):
return number**(1/n)
HTH,
Alan G.
Catching up on mail aftrer 2 days out...
More information about the Tutor
mailing list