Suppose we have a number n. We have to check whether the number n is perfect square or not. A number is said to be a perfect square number when its square root is an integer.
So, if the input is like n = 36, then the output will be True as 36 = 6*6.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
from math import sqrt def solve(n): sq_root = int(sqrt(n)) return (sq_root*sq_root) == n n = 36 print (solve(n))