Answered You can hire a professional tutor to get the answer.

QUESTION

questions from Python, 1. Define a functionis_primethat receives an integer argument and returns true if the argument is a prime number and otherwise...

questions from Python,

1.

Define a functionis_primethat receives an integer argument and returns true if the argument is a prime number and otherwise returns false. (An integer is prime if it is greater than 1 and cannot be divided evenly [with no remainder] other than by itself and one. For example, 15 is not prime because it can be divided by 3 or 5 with no remainder. 13 is prime because only 1 and 13 divide it with no remainder.) This function may be written with a for loop, a while loop or using recursion.

2.

Assume the availability of a functionis_prime. Assume avariablenhas been associated with positive integer. Write the statements needed to compute the sum of the firstnprime numbers. The sum should be associated with thevariabletotal.

Note:is_primetakes an integer as a parameter and returnsTrueif and only if that integer is prime.

3.

Assume there are twovariables,kandm, each already associated with a positive integer value and further assume thatk's value is smaller thanm's. Write the code necessary to compute the number of perfect squares betweenkandm. (A perfect square is an integer like9,16,25,36that is equal to the square of another integer (in this case3*3,4*4,5*5,6*6respectively).) Associate the number you compute with thevariableq. For example, ifkandmhad the values10and40respectively, you would assign3toqbecause between10and40there are these perfect squares:16,25, and36,.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question