Articles

# Python program to print all the perfect square number in the given range

In this python program guide, we will learn:

• perfect squares in the given range in python

### 🤷‍♀️🤷‍♀️What do you mean by perfect square number ?

A number is said to be a perfect square number if it can be obtained by the multiplication of two equal integer numbers.

for example,

16 is a perfect square number because it can be obtained by the multiplication of two equal integers (4*4=16).

our task is to find all the perfect squares number in the given range by the user.

So let’s start to find the solution to this tricky problem.

### 📙📙 Print perfect square numbers in python in range

Code to print perfect square numbers in python is given below:

``````# perfect square number in the given range
i=1
t=int(input("please enter the range till program runs "))
for j in range(1,t+1):   # range from 1 to t
while(i<=((j//2)+1)):
if(i**2==j):
print(j)
i+=1
i=1``````

👉👉the program will print the perfect square number in the given range as inputted by the user.

### 🤷‍♀️🤷‍♀️🤷‍♀️Output to the above program in python is given below:

``````please enter the range till program runs 133
1
4
9
16
25
36
49
64
81
100
121``````

Our program prints the perfect square number from 1 to the given range.

📖🎯Screenshot of running  program in jupyter notebook: As we can see our program prints the perfect square numbers in the given range. So,our program has been run successfully.

Similarly, we can print all the perfect square number between 1 and 500 in python or any range.

Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com 