Code:

```
def find_next_square(sq):
# Return the next square if sq is a square, -1 otherwise
sq2=(sq**1/2)
xyz=isinstance(sq2, int)
if (xyz==True):
print("Is perfect square")
nextsq=sq+1
print("Next perfect square=",nextsq**2)
else:
print("Not perfect square")
return -1
n=int(input("Enter an integer"))
find_next_square(n)
```

Enter an integer25

Not perfect square

Expected output-:

Enter an integer25

Next perfect square=36

My logic is that xyz checks if $(sq)^0.5$ is integer or not. If it is integer we find next perfect square, else we return -1

Last edited: