PYTHON PORGRAM TO CHECK WHETHER a NUMBER is a PERFECT SQUARE/NOT

Published: 01 January 1970
on channel: PythonEnthusiasts
14
0

PYTHON PORGRAM TO CHECK WHETHER a NUMBER is a PERFECT SQUARE/NOT

import numpy as np


1.find the square root of the number,convert it into integer
2.find the sqaure for the square root
3.compare original to square of the sqaure root

def check_perfect_square(num):
square_root_num = int(np.sqrt(num))
square_num = square_root_num * square_root_num
if (num == square_num):
print("GIVEN NUMBER IS A PERFECT SQUARE")
else:
print("GIVEN NUMBER IS NOT A PERFECT SQUARE")


my_num = int(input("ENTER THE NUMBER"))
check_perfect_square(my_num)