First perfect square in Python

Problem Statement:

In this problem of the first perfect square in Python, we are given two numbers and we need to find the first perfect square that lies in the range of these two numbers.

Code for first perfect square in Python:

import math

n1 = 26
n2 = 40

for i in range(n1, n2 + 1):
    if math.ceil(math.sqrt(i)) == math.floor(math.sqrt(i)):
    print('No perfect square between ', n1, ' and ', n2)


Output for First perfect square in Python

Also Read:


Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at Thank you