To find the given number is a perfect square or not?

Hello programmers,

Need a help on check if there is any other way to code the below code to find out if the number entered by a user is a perfect square or not?

print(“Enter a number to see if it is a perfect square or not”)
num = input()
num = eval(num)
i = -1
square = False
while num >=0 and num%1 == 0:
i = num ** (0.5)
if i * i == num:
square = True
break
i = i+1
if square:
print(‘It is a square.’ + 'The square root of the given number is: ', i)
else:
print(‘Not a square’)

If there is an effective way of writing this. Please post it as a reply.

Thanks.

Welcome to the forum, @data7421740119.

For starters, your code is easier to read if you post it inside the </>. See this link.

Second, why did you initialize the value of i to -1? It’s hard to be sure without indents in your code, but it appears that value isn’t used.