1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Oliga [24]
3 years ago
13

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,.
PYTHON CODING
Computers and Technology
1 answer:
ehidna [41]3 years ago
8 0

Answer:

import math  

def isPerfectSquare(n):

 s = int(math.sqrt(n))

 return n == s*s

def countPerfectSquares(k,m):

 q = 0

 for i in range(k,m):

   if isPerfectSquare(i):

     q=q+1

 return q

print(countPerfectSquares(10,40))

Explanation:

Note that this is including the k, but excluding m. If you want to include m, write m+1 in the range expression.

You might be interested in
Evaluate the following expression with precedence of operator:<br> ​ X = 2* 3/ 5 + 10 //3 – 1
Mamont248 [21]

Answer:  3.5333 repeating

Explanation:

2 times 3/5 equals 1.2, 1.2 plus 10 equals 11.2, 11.2 divided by 3-1 equals 3.5333 repeating i think.

4 0
3 years ago
Which of these parts of a computer produces an observable result?
lara31 [8.8K]

Answer:

D

Explanation:

6 0
3 years ago
Read 2 more answers
_________ is an alternative name for the main memory.help me​
Leni [432]
RAM
(Random Access Memory)
7 0
3 years ago
Read 2 more answers
Which of the following answers refers to a system containing mappings of domain names to various types of data, such as numerica
BartSMP [9]

Answer:

DNS or Domain Name System

Explanation:

You can query a DNS server with a domain name to get an IP address.

5 0
4 years ago
Once a table is inserted into a publication, which two tabs become available?
rusak2 [61]

Answer:

insert i think sry if its wrong :(

Explanation:

7 0
3 years ago
Other questions:
  • In windows vista, which process allows you to display two documents side by side?
    12·2 answers
  • Most of the pollution in the ocean comes from:
    11·1 answer
  • What is a binary digit
    7·1 answer
  • _____ supplement operating system software in ways that increase the security or capabilities of the computer system. firewalls,
    15·1 answer
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • Jack started a job as a consultant with an IT firm he will be interacting with various customers and employees from different pa
    13·1 answer
  • Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,
    7·1 answer
  • Any one know??please let me know
    15·2 answers
  • You have just purchased a new Dell PowerEdge R820 Rack Server. The server is equipped with four Xeon E5-4650 CPUs, 128 GB of RAM
    8·1 answer
  • Technological advancements during the industrial age provided Americans with:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!