Answer to Question #222432 in Python for srikanth

Question #222432
Perfect Squares in a Range

You are given two given numbers, 

A and B where 1 <= A <= B, Write a program to find the number of perfect squares in the range A to B (including A and B).

Input

The first line of input is an integer 

A. The second line of input is an integer B.

Explanation

In the given example, 

A = 9 and B = 100. The perfect squares in the range A to B are

3 * 3 = 9
4 * 4 = 16
5 * 5 = 25
6 * 6 = 36
7 * 7 = 49
8 * 8 = 64
9 * 9 = 81
10 * 10 = 100

So, the output should be 

8.

Sample Input 1
9
100
Sample Output 1
8
Sample Input 2
625
1444
Sample Output 2
14
1
Expert's answer
2021-08-02T07:13:17-0400
a = int(input())
b = int(input())
count = 0
for i in range(a, b + 1):
    if int(i ** 0.5) == i ** 0.5:
        count += 1
print(count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Lakshman
01.06.22, 04:33

Super website

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS