Learn about Python Program to Find Perfect Squares in Given Range in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Python Program to Find Perfect Squares in Given Range
# Program to print perfect square in range def PerfectSquare(a, b): for i in range(a, b + 1): if (i**(.5) == int(i**(.5))): print(i, end=" ") # inputs from user start = int(input('Enter start number: ')) end = int(input('Enter end number: ')) # function call PerfectSquare(start, end)
Enter start number: 8
Enter end number: 50
9 16 25 36 49
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Perfect Square in Python without using sqrt() method