()
| 5 | |
| 6 | |
| 7 | def cubeRoot(): |
| 8 | x = int(input("Enter an integer: ")) |
| 9 | for ans in range(0, abs(x) + 1): |
| 10 | if ans**3 == abs(x): |
| 11 | break |
| 12 | if ans**3 != abs(x): |
| 13 | print(x, "is not a perfect cube!") |
| 14 | else: |
| 15 | if x < 0: |
| 16 | ans = -ans |
| 17 | print("Cube root of " + str(x) + " is " + str(ans)) |
| 18 | |
| 19 | |
| 20 | cubeRoot() |