Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A prime number is a number (not including 1) that is only evenly divisible by two numbers: itself and 1. For example, the number

A prime number is a number (not including 1) that is only evenly divisible by two numbers: 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 a Boolean function named is_prime which takes an integer as an argument and returns True if the argument is a prime number, or False otherwise. Then, in the main function, prompt the user to enter a number. If the user enters -1, end the program. Otherwise, display a message indicating whether or not the number is prime, using your is_prime function to decide which message to display. Input Number 1 not prime prime not prime prime quit Table 1: Test data for Exercise 04.4. 2 10 Output Status 4001 -1 Test your program with the data in Table 1. Finally, format your program to match the sample output, character for character, including all white space and punctuation. User in- put in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your finished Python program as prime_numbers_login.py, where login is your Purdue login. Then submit it along with a screenshot showing a run of all 5 test cases. Terminal $ python prime_numbers_login.py Enter a positive integer (-1 to quit): 1 1 is not prime. Enter a positive integer (-1 to quit): 2 2 is prime! Enter a positive integer (-1 to quit): 10 10 is not prime. Enter a positive integer (-1 to quit): 4001 4001 is prime! Enter a positive integer (-1 to quit): -1 $

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a Python program th... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finite Mathematics and Its Applications

Authors: Larry J. Goldstein, David I. Schneider, Martha J. Siegel, Steven Hair

12th edition

978-0134768588, 9780134437767, 134768582, 134437764, 978-0134768632

More Books

Students also viewed these Programming questions