I am creating a problem which requires me to find the cube root of certain numbers, some of them have whole number roots, but a lot of them don\'t.
I have numbers li
Avoid any hacks with floats and tolerance levels, these are often unreliable for large inputs. A better tool for the job is to use a multiple precision arithmetic library such as gmpy2:
>>> import gmpy2 >>> root, exact = gmpy2.iroot(125, 3) >>> print(root) 5 >>> print(exact) True