First, PrimeFinder should ask how many numbers the user has decided to pass to PrimeFinder using...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
First, PrimeFinder should ask how many numbers the user has decided to pass to PrimeFinder using the message 'How many numbers do you want to check? '. Let's call the provided number by user n. For n times PrimeFinder should print 'Enter a positive integer: ' and take a positive integer from the user. For each prime number, PrimeFinder prints out 'X is a prime number.' where X is the number provided by the user in that round. For each nonprime number PrimeFinder does not print out a message. PrimeFinder assumes that its users are smart enough not to enter a float number. If the user inserts a negative number PrimeFinder should ignore it and inform the user by the message 'PrimeFinder ignores negative numbers!'. For instance, if n=2 the user-provided sequence of numbers can be 3, 5 or 2, -4, -7, 5. In other words, PrimeFinder will continue working until it gets exactly positive integers. Finally, PrimeFinder prints out the total count of prime numbers received from the user, Y, in the following format: 'Total prime numbers: Y'. Figure 3 shows a sample output of PrimeFinder. You must name your code file q3.py and upload it to the HW1Q3: PrimeFinder section on Gradescope. How many numbers do you want to check? 3 Enter a positive integer: 4 Enter a positive integer: 1-2 PrimeFinder ignores negative numbers! Enter a positive integer: 2 2 is a prime number. Enter a positive integer: 47 47 is a prime number. Total prime numbers: 2 First, PrimeFinder should ask how many numbers the user has decided to pass to PrimeFinder using the message 'How many numbers do you want to check? '. Let's call the provided number by user n. For n times PrimeFinder should print 'Enter a positive integer: ' and take a positive integer from the user. For each prime number, PrimeFinder prints out 'X is a prime number.' where X is the number provided by the user in that round. For each nonprime number PrimeFinder does not print out a message. PrimeFinder assumes that its users are smart enough not to enter a float number. If the user inserts a negative number PrimeFinder should ignore it and inform the user by the message 'PrimeFinder ignores negative numbers!'. For instance, if n=2 the user-provided sequence of numbers can be 3, 5 or 2, -4, -7, 5. In other words, PrimeFinder will continue working until it gets exactly positive integers. Finally, PrimeFinder prints out the total count of prime numbers received from the user, Y, in the following format: 'Total prime numbers: Y'. Figure 3 shows a sample output of PrimeFinder. You must name your code file q3.py and upload it to the HW1Q3: PrimeFinder section on Gradescope. How many numbers do you want to check? 3 Enter a positive integer: 4 Enter a positive integer: 1-2 PrimeFinder ignores negative numbers! Enter a positive integer: 2 2 is a prime number. Enter a positive integer: 47 47 is a prime number. Total prime numbers: 2
Expert Answer:
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these programming questions
-
To meet the rising demand for its finished products, Xenon Inc., is automating its manufacturing process. However, most of Xenon's employees prefer the previous process and are finding it difficult...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
South Sea Baubles has the following (incomplete) balance sheet and income statement. a. What is shareholders' equity in 2013 and 2014? b. What is net working capital in 2013 and 2014? c. What are...
-
A uniform slender L-shaped bar ABC is at rest in a vertical plane when two upward forces are applied as shown. Knowing that the mass of the bar is 20 kg, determine (a) The initial angular...
-
Consider the program evaluation problem where w is the binary treatment indicator and the potential outcomes are y(0) and y(1), as we discussed in Sections 3-7e, 4-7, 7-6a, and elsewhere. For a set...
-
Suppose that \(x_{i}\) only takes on the values 0 and 1. Out of the \(n\) observations, \(n_{1}\) take on the value \(x=0\). The \(n_{1}\) observations have an average \(y\) value of \(\bar{y}_{1}\)....
-
McTaggart-Hicks transactions as operating (O), investing (I), financing (F), non-cash investing and financing (NIF), or a transaction that is not reported on the statement of cash flows (N). Indicate...
-
Environmental friendly marketing indicates marketing of environment friendly products and services. What can we call such marketing strategies that create long term customer relationship along with...
-
LUKE'S GENERAL STORE Inventory December 31, 20X7 Price Test Results Proper Action (select one): Test Test Count Item Description Auditor Notes (last purchased Item# Results: price): Boxes appear...
-
Les and Marg Linehan are both in the late 60s and have been clients of the practice for many years, mainly dealing with James. They have one child, a son Robert, with whom they have a strained...
-
what laws govern business and consumer banking transactions?
-
The truck has an salvage value ofsz,400, andis epected to be diven 110.000 maesover as estimated useful Be of s years. Actual miles driven were 15,500 in 2017 and 13,800 in 2018 v (al Your answer is...
-
Discuss the role that wholesale banking plays in economic development?
-
discuss the interplay between internal and external conflicts in shaping the complexities of character motivations and actions within literary works ?
-
How the lending system is applied in the merchant of Venice?
-
Enter the solubility-product expression for Mg3(PO4)2(s).IncludeChargs. Ksp=
-
Draw two scatterplots, one for which r = 1 and a second for which r = 21.
-
Reconsider the Wyndor Glass Co. case study introduced in Section 2.1. Suppose that Bill Tasto (Wyndor's vice president for manufacturing) now has found a way to provide a little additional production...
-
You are given the following decision tree, with the probabilities at event nodes shown in parentheses and with the payoffs at terminal points shown on the right. Analyze this decision tree to obtain...
-
Read the referenced article that fully describes the management science study summarized in the application vignette presented in Section 10.3. Briefly describe how forecasting was applied in this...
-
Cinnamon, Inc. recorded a total deferred tax asset in Year 3 of \($12\),301, off set by a \($12\),301 valuation allowance. Cinnamon most likely: A . fully utilized the deferred tax asset in Year 3. B...
-
Compared to the provision for income taxes in Year 3, the companys cash tax payments were: A . lower. B . higher. C . the same.
-
Midland Brands issues three-year bonds dated January 1, 2015 with a face value of $5,000,000. Th e market interest rate on bonds of comparable risk and term is 3%. If the bonds pay 2.5% annually on...
Study smarter with the SolutionInn App