How would you write main() as specified in the img below? This is what I have written(and it works) but it does not meet the requirments asked to have in main(), and likewise of determine_prime() as the actual text string should be produced in main(); def get_intro(): print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("In Math, prime numbers are whole numbers greater than 1, that have only two factors the number 1 and the number itself.") print("This program will calculate if a number you enter is prime.") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") def validate_input(): while True: try: newNum = int(input("Enter a postive whole number to check if it is prime: ")) if newNum <= 0: print("Value must be a whole number greater than 0!") continue except ValueError: print("Value must be a whole number!") continue else: return newNum def determine_prime(isWhole): if isWhole < 2: # catch 1 and anything less than zero print("The definition of a prime number is a positive interger that has exactly two positive divisors.") print("The number 1 only has one positive divisor, so the number 1 is not prime.") else: prime = True for i in range(2, isWhole): if isWhole%i == 0: print("This number", isWhole,"is not prime") prime = False break if prime: print("This number", isWhole,"is prime") return isWhole def main(): get_intro() isWhole = validate_input() determine_prime(isWhole) do_again() def do_again(): print("Do you want to run the program again? ('Y' for yes, anything else to quit.)") cont = input() # Start cont = "Y" while cont == "Y": main()
How would you write main() as specified in the img below?
This is what I have written(and it works) but it does not meet the requirments asked to have in main(), and likewise of determine_prime() as the actual text string should be produced in main();
def get_intro():
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("In Math, prime numbers are whole numbers greater than 1, that have only two factors the number 1 and the number itself.")
print("This
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
def validate_input():
while True:
try:
newNum = int(input("Enter a postive whole number to check if it is prime: "))
if newNum <= 0:
print("Value must be a whole number greater than 0!")
continue
except ValueError:
print("Value must be a whole number!")
continue
else:
return newNum
def determine_prime(isWhole):
if isWhole < 2: # catch 1 and anything less than zero
print("The definition of a prime number is a positive interger that has exactly two positive divisors.")
print("The number 1 only has one positive divisor, so the number 1 is not prime.")
else:
prime = True
for i in range(2, isWhole):
if isWhole%i == 0:
print("This number", isWhole,"is not prime")
prime = False
break
if prime:
print("This number", isWhole,"is prime")
return isWhole
def main():
get_intro()
isWhole = validate_input()
determine_prime(isWhole)
do_again()
def do_again():
print("Do you want to run the program again? ('Y' for yes, anything else to quit.)")
cont = input()
# Start
cont = "Y"
while cont == "Y":
main()
![In Math, prime numbers are whole numbers greater than 1, that have only two factors the number 1 and the number itself.
This program will calculate if a number you enter is prime
Enter a positive whole number to check if it is prime: -1
Value must be a whole number greater than e!
Enter a positive whole number to check if it is prime: e
Value must be a whole number greater than 0!
Enter a positive whole number to check if it is prime: three
Value must be a whole number!
Enter a positive whole number to check if it is prime: 7
This number 7 is prime
Do you want to run the program again? ('Y' for yes, anything else to quit)
y
In Math, prime numbers are whole numbers greater than 1, that have only two factors the number 1 and the number itself.
This program will calculate if a number you enter is prime
Enter a positive whole number to check if it is prime: 1
The definition of a prime number is a positive integer that has exactly two positive divisors.
The number 1 only has one positive divisor, so the number 1 is not prime.
Do you want to run the program again? ('Y' for yes, anything else to quit)
y
In Math, prime numbers are whole numbers greater than 1, that have only two factors the number 1 and the number itself.
This program will calculate if a number you enter is prime
Enter a positive whole number to check if it is prime: 56
This number 56 is not prime
Do you want to run the program again? ('Y' for yes, anything else to quit)
n](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa9dcdc3c-6dc3-477b-85c7-36dea293e258%2F01ce258d-a4fe-436a-a3d2-4f89ccdfbfc9%2Faj4l5wj_processed.jpeg&w=3840&q=75)
![A prime number is a number that is only evenly divisible by itself and 1. For example, the
number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is
not prime because it can be divided evenly by 1, 2, 3, and 6. Write program that prompts the
user to enter a number then displays a message indicating whether the number is prime.
The program must contain the following functions (named as defined below). Each function
must perform the task outlined next to it
main() – controls program. Displays if the number is prime. Produces a special message if the
user entered a 1 for user input.
get_intro() - Displays an introduction to the program.
determine_prime() - Uses modulus to determine if a number is prime. Returns a Boolean value.
validate_input() – validates that user input is a positive whole number. Entering in a string or
float must not break the program. Use try\except. Returns int
do_again() – asks the user if they want to restart the program. Program must not break but start
or exit cleanly.
main()
get_intro()
determine_prime()
validate_input()
do_again()](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa9dcdc3c-6dc3-477b-85c7-36dea293e258%2F01ce258d-a4fe-436a-a3d2-4f89ccdfbfc9%2Fy9859n3_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)