nth root of a number python

Solutions on MaxInterview for nth root of a number python by the best coders in the world

showing results for - "nth root of a number python"
Erica
08 Mar 2017
1## How this will work is it takes the n to the power -1 root of num
2## n to the power -1 is just 1 over n
3
4def root(num, n):
5  return a**(n**-1)
6
7print(root(27, 3))
Pietro
30 Aug 2020
1def nthrootofm(a,n):
2    return pow(a,(1/n))
3a=81
4n=4
5q=nthrootofm(a,n)
6print(q)
7