Question: (10 pts) is prime: Re-write the is_prime function (given here) in one statement of code. Note: one statement, not one line of code. You can

 (10 pts) is prime: Re-write the is_prime function (given here) inone statement of code. Note: one statement, not "one line of code".

(10 pts) is prime: Re-write the is_prime function (given here) in one statement of code. Note: one statement, not "one line of code". You can assume the input will be larger than 2, so no need to worry about special cases. Use a generator expression with one of the built-in functions from week 1, and don't copy random stuf from the internet. Note that the function should contain a generator expression, not be a generator function No Sieve of Eratosthenes, or other unusual stuff. We are not interested in efficiency, the point is to figure out how to do it with the tools you have been given. Think about what the for loop and the test inside really mean in order for it to return True def is_prime(candidate): for n in range(2, candidate): if candidate % n 0: return False return True You can use these to test: >>from HW6 import is_prime >>is_prime (2) True >>is_prime (3) True >is_prime (999979) True >is_prime (53) True >>is_prime (345) False >>is_prime (95) False >is_prime (51) False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!