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.
-
Summer Design Company was organized on January 1, 2014, by Corinne Burien. Summer Design records all prepaid costs as expenses and all revenues received in advance as revenue. At the end of the first...
-
Consider the data for Business Weeks top U.S. MBA programs in the MBA Data sheet of the file P10_21.xlsx. Use these data to estimate a multiple regression model to assess whether there is a...
-
Prepare and use contribution margin statements for dropping a line decision (Learning Objective 4) The following operating income data of Abalone Seafood highlight the losses of the fresh seafood...
-
Proprietary Fund Financial Statements. Von County has prepared the following statement of revenues, expenses, and changes in fund net assets for its proprietary funds. The county has three enterprise...
-
Refer to the figure below to find the limit lim f(x) What is the limit? Select the correct choice below and, if X- - 00 `necessary, fill in the answer box to complete your choice. + O A. lim f(x) =...
-
Grimes Corporation began business in 2017 and incurred losses for its first two years. In 2019, it became profitable. The following table shows Grimess taxable income before consideration of its...
-
A project requires a $43,000 initial investment and is expected to generate end-of-period annual cash inflows as follows: Year 1 $ 17,200 Year 2 $ 10,600 Year 3 $ 15,200 Total $ 43,000 Help Save &...
-
Frameworks differ in that they might offer varying levels of depth and breadth when compared with each other. A. True B. False
-
Certification andeccreditatfon is an audit of federal systems prior to being placed into a production environment.
-
SAS 70 Type I includes everything in a SAS 70 Type II report, but it adds a detailed testing of the controls over a specific time frame. A. True B. False
-
\(\operatorname{CoSO}\) is the acronym for which of the following? A. Compliance Objectives Standards Organization B. Committee of Sponsoring Organizations C. Compliance Organization Standard...
-
Which of the following should organizations do when selecting a standard? (Select three.) A. Select a standard that can be followed. B. Employ the selected standard. C. Select a flexible standard. D....
-
Find the first derivative with respect to x. -2x7 - 9y4 + 7y = 8 dy dx =
-
Show that the block upper triangular matrix A in Example 5 is invertible if and only if both A 11 and A 22 are invertible. Data from in Example 5 EXAMPLE 5 A matrix of the form A = [ A11 A12 0 A22 is...
-
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...
-
Saxon wants to know if its profitability performance has increased from 20x6 to 20x7. The company had net income of $24,000 in 20x6 and $25,000 in 20x7. Total assets were $200,000 at the end of 20x5,...
-
Below is a list of financial statement items. Required 1. Indicate whether each item is found on the income statement (IS), statement of retained earnings (RE), and/or balance sheet (BS). 2. User...
-
Below are three independent sets of financial statements with several amounts missing. Required 1. Complete each set of financial statements by determining the amounts that correspond to the letters....
Study smarter with the SolutionInn App