- Details
- Parent Category: Programming Assignments' Solutions
We Helped With This Python Programming Homework: Have A Similar One?
Assignment Description
The goal of this task is to create a Python program that prompts the user to enter 2 numbers. Your Python code must be stored in a file called primes.py. Your program then prints out all of the prime numbers strictly between those 2 numbers in increasing order. If there are no prime numbers strictly between those 2 numbers, then a No Primes message is printed out. The order that the numbers were entered does not matter.
Output: If there are no primes between the two numbers, your code outputs exactly:
No Primes
If there is one prime number, only that 1 number prints out.
If there are multiple prime numbers, the following pattern is used:
firstNum:secondNum!thirdNum,fourthNum:fifthNum!sixthNum,seventhNum
In other words, you separate the first number from the second number with a colon. You separate the second number from the third number with an exclamation point. You separate the third number from the fourth number with a comma. This pattern of separation is repeated in subsequent numbers (colon, exclamation point, comma) until there are no more numbers left to be printed. Note there is no delimiter before the first element nor is there a delimiter after the last element.
Example: For example, if 5 and 24 were entered in that order, then 7:11!13,17:19!23 would print out. If 24 and 5 were entered in that order, then 7:11!13,17:19!23 would print out. |
Output: If there are no primes between the two numbers, your code outputs exactly:
No Primes
If there is one prime number, only that 1 number prints out.
If there are multiple prime numbers, the following pattern is used:
firstNum:secondNum!thirdNum,fourthNum:fifthNum!sixthNum,seventhNum
In other words, you separate the first number from the second number with a colon. You separate the second number from the third number with an exclamation point. You separate the third number from the fourth number with a comma. This pattern of separation is repeated in subsequent numbers (colon, exclamation point, comma) until there are no more numbers left to be printed. Note there is no delimiter before the first element nor is there a delimiter after the last element.
Example: For example, if 5 and 24 were entered in that order, then 7:11!13,17:19!23 would print out. If 24 and 5 were entered in that order, then 7:11!13,17:19!23 would print out. |
You are not allowed to use any external libraries to solve this problem (e.g. numpy, sympy, etc).