Question: Write and test the following function: def detect _ prime ( number ) : - - - - - - - -

Write and test the following function:
def detect_prime(number): """------------------------------------------------------- Determines if number is a prime number. Use: prime = detect_prime(number)------------------------------------------------------- Parameters: number - an integer (int >1) Returns: prime - True if number is prime, False otherwise (bool)------------------------------------------------------"""
Add the function to a PyDev module named functions.py. Test it from .
A prime number is a positive integer greater than 1 which has no other factors except 1 and the number itself. 2,3,5, and 7 are prime numbers as they can only be divided by 1 and by themselves to give a whole number. 4 is not a prime because, 4 can be divided by 1,2 and 4.
The function does not ask for input and does no printing - that is done by your test program.
The function must use a while loop.
Sample execution:
detect_prime(131)-> True

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 Programming Questions!