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:
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/65005e7b72b43_1694523001478.jpg)
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.
-
Fill in the two authorization tables for Pine Valley Furniture Company below, based on the following assumptions (enter Y for yes or N for no): Salespersons, managers, and carpenters may read...
-
A production function is given by P(x, y) = 400x 0.3 y 0.7 , where x is the number of units of labor and y is the number of units of capital. Find the average production level if x varies from 40 to...
-
It has been said that a key difference between CCPM safety and ordinary PERT chart activity slack is that activity slack is determined after the network has been created, whereas critical chain path...
-
Write a program that will read data from the file "p6.txt". The file (that you will create) always contains 15 test scores (whole numbers between 0 and 100). The test scores are scores for 5 students...
-
Koen Corporation has two divisions: Division A and Division B. Last month, the company reported a contribution margin of $41,400 for Division A. Division B had a contribution margin ratio of 25% and...
-
Managers at Wagner Fabricating Company are reviewing the economic feasibility of manufacturing a part that the company currently purchases from a supplier. Forecasted annual demand for the part is...
-
Which of the following is true of ratification by the principal? Group of answer choices It can only occur prior to the actions of the agent. It is a voluntary act by the principal. It discharges the
-
The adjusted trial balance section of Menlo Company's worksheet shows a \(\$ 1,500\) debit balance in utility expense. At the end of the accounting period the accounting manager accrues an additional...
-
Identify each of the 10 amount columns of the worksheet and indicate to which column the adjusted balance of the following accounts would be extended: a. Accounts Receivable b. Accumulated...
-
Using the data from Table 3.3, show the effect on world output if each country moved toward specialization in the production of its comparative-disadvantage good. TABLE 3.3 Comparative Advantage as a...
-
The Professional Winner was RJ Andrews from Info We Trust, for the video Are Gazelles Endangered? (a) Watch this video. What data are this video conveying? (b) You can interact with the data and...
-
(a) Draw a simplified ray diagram showing the three principal rays for an object located outside the focal length of a converging lens. (b) Is the image real or virtual? (c) Is it upright or...
-
Jamco Corp has an outstanding bond with a coupon rate of 5.0% and makes annual payments. The bond currently sells for $1,100, matures in 12 years, and has a par value of $1,000. What is the YTM...
-
Find the center of mass of a thin triangular plate bounded by the y-axis and the lines y = x and y = 2 - x if (x, y) = 6x + 3y + 3.
-
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...
-
53. A city starts a public library that has separate incorporation and gets some of its money from the state and some from private donations. Indicate whether each of the following independent state...
-
RESEARCH CASE 1 The City ofAbernethy has three large bridges built in the later part of the 1980s that were not capitalized at the time. The citys accountant is interested in receiving suggestions as...
-
51. Use the same information as in problem 50 except that, by the end ofYear 3, the landfill is 40 per cent filled. The city realizes that the total closure costs will be $3 million. Indicate whether...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App