1def is_cube(n):
2 guess = n**(1.0/3.0)
3 iguess = int(guess)
4 if iguess * iguess * iguess == n:
5 print(True, "it's cubed root is", iguess)
6 return
7 iguess = iguess + 1
8 if iguess * iguess * iguess == n:
9 print(True, "it's cubed root is", iguess)
10 return
11 print(False, "it's cubed root is", guess)
12
13is_cube(9) # No
14is_cube(27) # Yes
1import math
2
3# Taking the input from user
4number = int(input("Enter the Number"))
5
6root = math.sqrt(number)
7if int(root + 0.5) ** 2 == number:
8 print(number, "is a perfect square")
9else:
10 print(number, "is not a perfect square")