import math

def root(num, r):
    base = num ** (1.0 / r)
roots = [base]
for i in range(1, r):
    roots.append(complex(base * math.cos(2 * math.pi * i / r), base * math.
        sin(2 * math.pi * i / r)))
return roots
Python - how to compute all nth roots of a number?