Question: Python 3.4 3.6 code: Create a menu-driven program that will calculate and display all the prime numbers between 2 and a user-entered limit. Your simple

Python 3.4 3.6 code:

Create a menu-driven program that will calculate and display all the prime numbers between 2 and a user-entered limit. Your simple menu should have only 3 options: 1. Create a list of primes from 2 to n using the Sieve of Eratosthenes algorithm.

2. Display the prime numbers

3. Quit

Program particulars: You must use standard list-traversal coding structures to perform your calculations. Get a limit (type int) from the user to represent the upper limit of the list.

There must be error checking on the input integer. If it not greater than 2, the program will print an error message and re-prompt. This process will continue until an integer greater than 2 is entered.

You must use a try-except structure to trap both types of input errors (like letters where numbers should go) and range errors (like < 2). There must be error checking on the menu choice entered. If the user enters a choice not on the menu, the program will print an error message, re-display the menu and re-prompt. This process will continue until a valid option value is entered. Your solution must be modular.

The design of your functions is up to you, but the rules of highly cohesive and loosely coupled must be followed. Your program should be well-documented. Explain what youre doing in your code. Be sure to include the usual name and assignment notes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!