To find the nth root of a number in Python, you can use the **
operator and the math.pow()
function. Here's an example of finding the 3rd root of the number 27:
main.py85 chars8 lines
In the code above, we import the math
module to use the pow()
function. We define the number we want to find the root of, num
, and the root we want to find, n
. We calculate the result using the pow()
function and print it to the console.
gistlibby LogSnag