Answer:
#section 1
def is_prime_v1(n):
for d in range(2, n):
if n % d == 0:
return False
return True
#section 2
while True:
try:
num = int(input('Enter a number greater than 2: '))
if num > 2:
break
else:
raise
except:
print('{} is not greater than 2'.format(num))
#section 3
for n in range(3, num):
is_prime_v1(n)
a=is_prime_v1(n)
if a==True:
print (n)
Step-by-step explanation:
The programming language used is Python 3.
#section 1
In this section we create a function that will check if a number is a prime number. The function returns True for prime numbers and False for normal numbers.
#section 2
In this section we make use of a WHILE loop and a try and except block to ensure that the input by the user is greater than two, if the input is less than 2, an exception is raised and the except block prompts the user to enter the appropriate value.
when the appropriate value is entered the loop breaks and the value is carried to the last section.
#section 3
In this final section, the value collected from the user in #section 2, is inserted as the upper-limit in a range function with the lower limit set at 3.
The function created in #section 1 is called and each value in the range is passed to it and an IF statement checks if the output is True or False. If the IF block evaluated to be True, it implies that the number is a prime number and the result is printed to the screen.