Question: In this assignment you are asked to write a Python program to determine all the prime numbers in between a range and store them in

In this assignment you are asked to write a Python program to determine all the prime numbers in between a range and store them in a list that will be printed when the range is searched. The user is prompted for two positive integer values as input, one is the start of the range and the other is the end of the range. If the user gives a negative value or enters a second number that is lower than the first input value, re-prompt them to enter a correct value. Both the start and the end input values should be inclusive in the range.

Hints:

1. Use a for loop to iterate through the range.

2. You can use a while or for loop to check whether a number is prime or not, but you must create a function to test whether an integer is prime or not. To do that, divide every number in the range by 2 up through half the number. If any of those divides evenly into your test number, the number is not prime and the function returns a Boolean False. Otherwise, it is prime and the function returns True.

3. If the function returns True for a number, append it to the list.

4. After the end of the range is reached, print the list by iterating using a for loop.

5. Start by writing code to use a range of 0 to some number (i.e. 0 to 25), then when your tests show that works add the starting range value (i.e. 20 to 100).

Please make it simple to read as possible. I'm a beginner.

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!