Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions