Formulate a function called is prime that takes a number, and prints is Prime if...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Formulate a function called is prime that takes a number, and prints " is Prime" if it is prime and is Not Prime" if it is not (filling in the blank with the number passed) Formulate a main function that calls is_prime several times, once for each of these numbers (which should be passed as its parameter): 0,1,2,3,4,5,6,7,8,9 Add this to the bottom of your program: if _name__=='__main__": main() Remember: 0 and 1 are not prime! 2 is Prime and numbers after 2 are prime if they are not a product of two smaller numbers (ie. not a multiple). Please be careful with indentation - ensure that all of your code is either in your is prime function or in the main function. It should look like this: def is prime (num): #check if num is prime, print the result def main(): #call is_prime 10 times (using a loop), passing it each of the following if _name__='___main__': main() numbers: 0,1,2,3,4,5,6,7,8,9 Formulate a function called is prime that takes a number, and prints " is Prime" if it is prime and is Not Prime" if it is not (filling in the blank with the number passed) Formulate a main function that calls is_prime several times, once for each of these numbers (which should be passed as its parameter): 0,1,2,3,4,5,6,7,8,9 Add this to the bottom of your program: if _name__=='__main__": main() Remember: 0 and 1 are not prime! 2 is Prime and numbers after 2 are prime if they are not a product of two smaller numbers (ie. not a multiple). Please be careful with indentation - ensure that all of your code is either in your is prime function or in the main function. It should look like this: def is prime (num): #check if num is prime, print the result def main(): #call is_prime 10 times (using a loop), passing it each of the following if _name__='___main__': main() numbers: 0,1,2,3,4,5,6,7,8,9
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Simplify the expression. 32 11 72 11 32 11 72 11 (Type an integer or a simplified fraction.) example 13 Q Search
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
would you please let me know the gearing ratio ?
-
In a survey of 106 college students, data were gathered on the number of piercings each student had and the number of classes they had skipped in the past 3 weeks. We want to determine whether there...
-
Prob. 9.170 for the component described in the problem indicated, determine (a) The principal moments of inertia at the origin, (b) The principal axes of inertia at the origin. Sketch the body and...
-
For the system shown in Figure P4.8, a step torque is applied at 1 (t). Find: a. The transfer function, G(s) = 2 (s)/T(s) b. The percent overshoot, settling time, and peak time for 2 (t). ff 2...
-
Price Differentiating E-commerce websites "alter results depending on whether consumers use smartphones or particular web browsers," 34 reports a new study. The researchers created clean accounts...
-
Genesis Sportswear Ltd. is a wholesale company that buys sports clothing from manufacturers and sells it to retail stores. It had the following transactions in its first year of operations. The...
-
Monty Inc. issues 500 shares of $10 par value common stock and 100 shares of $100 par value preferred stock for a lump sum of $109,000. (a) Prepare the journal entry for the issuance when the market...
-
Emergency calls to the 911 system of Durham, North Carolina, for the past 24 weeks are shown in the following table: a) Compute the exponentially smoothed forecast of calls for each week. Assume an...
-
John has had a very good year and has over $600,000 of taxable income, including a sizable amount of capital gains. He's thinking of selling a large block of stock to a neighbor at a price...
-
If 43x+2=16x+4, then x equals
-
The following code format represents an instruction that deals with a destination register and a source memory location. If the microcontroller was of RISC architecture, calculate: 1 - Number of...
-
Write a c program on how many number divided by 4 in 1 2 3 0 2 4 2 ?
-
Describe your professional goals within Data Analyst track track. How will a TechWomen mentorship programm will help you achieve your professional goals?
-
You need to assign a common identifier for trade items that have been developed by an international organization. Which feature should you configure?
-
Financial Accounting: Using the following information add the transactions to T-accounts and Journal transactions. Scenario: You are the administrative assistant to the Real Art Studio and are...
-
On 1 July 2021, Croydon Ltd leased ten excavators for five years from Machines4U Ltd. The excavators are expected to have an economic life of 6 years, after which time they will have an expected...
-
What are cookies, and why are they used?
-
Explain the core competency argument for outsourcing and compare/contrast it with TCE theory. Why does one theory tend to prevail over the other in making out- sourcing decisions?
-
Prepare the 3NF base tables needed to produce the sales report view shown in the diagram forProblem. NoRMAIZATION OF DATA Sales Report Customer Number: 19321 Customer Name : Jon Smith Address : 520...
-
Henry Ford, founder of Ford Motor Company, is quoted as saying that customers could choose a car in any color as long as it was black. Things have come a long way since that timewhen customization...
-
Not long ago, New England Confectionery Company, or Necco for short, marked the production of its one trillionth candy wafer. The humble roots of Necco, the country's oldest continuously operating...
-
What is utility?
Study smarter with the SolutionInn App