Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k ‘s value is smaller than m ‘s.

LANGUAGE:  PYTHON

CHALLENGE:

Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k ‘s value is smaller than m ‘s.
Write the code necessary to compute the number of perfect squares between k and m.
(A perfect square is an integer like 9 , 16 , 25 , 36 that is equal to the square of another integer (in this case 3*3 , 4*4 , 5*5 , 6*6 respectively).)

Associate the number you compute with the variable q.
For example, if k and m had the values 10 and 40 respectively, you would assign 3 to q because between 10 and 40 there are these perfect squares: 16, 25, and 36,.

SOLUTION:


q = 0 
sqrtk = int(k**0.5) 
sqrtk += 1 
sqrtm = int(m ** 0.5) 
if sqrtm ** 2 != m: 
    >>sqrtm += 1 
for i in range(sqrtk, sqrtm): 
    >>q += 1