Questions from Python 1 Define a function

that receives an integer argument and returns


questions from Python,


Define a function is_prime that 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.


Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the statements needed to compute the sum of the first n prime numbers. The sum should be associated with the variable total.

Note: is_prime takes an integer as a parameter and returns True if and only if that integer is prime.


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 between10 and 40 there are these perfect squares: 16, 25, and 36,.

Engineering Technology