Answers for "how to check if a number is a perfect square python"

2

check if a number is perfect cube in python

x = int(input())
print(int(round(x ** (1. / 3))) ** 3 == x)
Posted by: Guest on August-24-2020
1

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
Posted by: Guest on January-14-2021
0

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")
Posted by: Guest on September-09-2021
1

python num perfect squares

print(int(int(n)**.5))
Posted by: Guest on July-24-2020

Code answers related to "how to check if a number is a perfect square python"

Python Answers by Framework

Browse Popular Code Answers by Language