Answer to Question #229886 in Python for kaavya

Question #229886

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-27T05:13:24-0400
A = int(input())
B = int(input())
count=0
for i in range(A, B + 1):
    if i ** 0.5 == int(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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS