ANONYMOUS wrote:
Hi. I have a problem on calculating cube root and sqcube for large number. For example cube root of 1000 is 10 but when i calculate it using python (1000 ** (1/3)) my output always 9.99999999 leading to output alway being 1 unit wrong from the result. i have tried abs, round non of them work. How can i fix this problem
This is because by doing ** (1/3)
in Python you have turned this int a floating point calculation. There are ways to make this work, but you do not need to.
Remember that we encourage you to speak to lab facilitators to help you work through the process of solving the problem, and there are hints on the lab sheet for if you get stuck.
I will point out that squares and cubes are defined as being the square or cube of some integer. You appear to be focusing on trying to test a given number to determine if it is a square or a cube. Is there some other way you could determine what numbers in a range are squares and what are cubes without testing them all individually?
Cheers,
Gozz