check if a number is perfect cube in python
x = int(input())
print(int(round(x ** (1. / 3))) ** 3 == x)
check if a number is perfect cube in python
x = int(input())
print(int(round(x ** (1. / 3))) ** 3 == x)
check if number is perfect cube python
def is_cube(n):
guess = n**(1.0/3.0)
iguess = int(guess)
if iguess * iguess * iguess == n:
print(True, "it's cubed root is", iguess)
return
iguess = iguess + 1
if iguess * iguess * iguess == n:
print(True, "it's cubed root is", iguess)
return
print(False, "it's cubed root is", guess)
is_cube(9) # No
is_cube(27) # Yes
how to check if a number is a perfect square python
import math
# Taking the input from user
number = int(input("Enter the Number"))
root = math.sqrt(number)
if int(root + 0.5) ** 2 == number:
print(number, "is a perfect square")
else:
print(number, "is not a perfect square")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us