Answers for "if it is square python"

4

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
0

if it is square python

def is_square(n):
    for i in range(n):
        print(i)
        if i*i == n:
            return True
        else:
            continue
print(is_square(4))
Posted by: Guest on February-26-2022

Python Answers by Framework

Browse Popular Code Answers by Language