A prime number is a number (not including 1) that is only evenly divisible by two...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 $ 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 $
Expert Answer:
Related Book For
Finite Mathematics and Its Applications
ISBN: 978-0134768632
12th edition
Authors: Larry J. Goldstein, David I. Schneider, Martha J. Siegel, Steven Hair
Posted Date:
Students also viewed these programming questions
-
According to the Innovators, explain how the transistor was discovered and how the transistor can be considered one of the greatest inventions of the 20th century. What insights can we learn from...
-
Record all transactions in appropriate T-accounts (costs by function, LIFO perpetual), close all accounts, and calculate the ending balances. Opening balances: Material A: 100 units x 2,5 / unit =...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Find the turning points on the curve y = 2x 3 5x 2 + 4x 1 and determine their nature. Find the point of inflection and sketch the graph of the curve.
-
For the frame and loading shown, determine the components of the forces acting on member ABC at B and C. SON E 192 N 60 120 mm 150 mm 120 mm 150 mm-
-
A rower wants to row her kayak across a channel that is 1400 ft wide and land at a point 800 ft upstream from her starting point. She can row (in still water) at 7 ft/s and the current in the channel...
-
How might a statistician challenge this argument that appeared The New York Times [10] in January 2014? Punishment and surveillance by itself causes people to withdraw from political...
-
When baseball players throw the ball in from the outfield, they usually allow it to take one bounce before it reaches the infield, on the theory that the ball arrives sooner that way. Suppose that...
-
Pitch a recommendation to a company of your choosing with your prediction of the potential success or downfall of Facebook and the MetaVerse for social media marketing. Essentially, would you...
-
Jill Connor is employed as a salesperson in the men's department of Fashion Line. In addition to her weekly base salary of $440, Connor is paid a commission of 2% on her total net sales for the week...
-
On December 31, 2023, News Mob Publishing receives $60,000 in cash from subscribers to cover the monthly delivery of magazines for one year, starting on January 1, 2024. On January 31, 2024, the...
-
Explain Hofstede's Restraint Versus Indulgence dimensions of national culture that can be used to distinguish between one country and another.
-
The functions g and h are given by g(x)=x+2 and h(x) = x (b) Find the values of x for which hg(x) = 3x+x-1
-
Ethical differences can be managed by court action or through mediation by the municipality. How does your municipality manage ethical discord with stakeholders?
-
Cyril, who is 68 years of age, received Social Security benefits of $12,000, wages of $5,000, interest and dividends of $4,000, unemployment compensation of $4,000 and municipal bond interest of...
-
Don Driller, who is 56 years old, is provided with $120,000 of group-term life insurance by his employer. Based on the IRS uniform premium cost table, the total annual cost of a policy of this type...
-
What is cloaca. Name an animal possessing this structure .
-
The following processes constitute the air-standard Diesel cycle: 12: isentropic compression,23: constant-volume energy addition (T and P increase),34: constant-pressure energy addition (v...
-
A manufacturing company has two plants, each capable of producing smartphones, tablets, and Bluetooth headphones. The daily production capacities of each plant are as follows. Plant I Plant II...
-
Consider the absorbing stochastic matrix A, where Approximate the stable matrix of A by raising A to a high power. Then find the exact stable distribution by calculating S(I - R)-1. 0.6 .1 .1 0 0 .2...
-
In 1913, Markov analyzed a long poem written by a Russian author. He found that vowels were followed by consonants 87.2% of the time (either in the same word or the next word) and that consonants...
-
In the research on leader behaviors, which style of leadership describes the preferred high-high combination? (a) transformational (b) transactional (c) laissez-faire (d) democratic
-
When managers use offers of rewards and threats of punishments to try to get others to do what they want them to do, they are using which type of power? (a) formal authority (b) position (c) referent...
-
In terms of leadership behaviors, someone who focuses on doing a very good job of planning work tasks, setting performance standards, and monitoring results would be described as _________. (a) task...
Study smarter with the SolutionInn App