Answered step by step
Verified Expert Solution
Question
1 Approved Answer
First, PrimeFinder should ask how many numbers the user has decided to pass to PrimeFinder using the message 'How many numbers do you want
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
Step by Step Solution
★★★★★
3.39 Rating (146 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started