# Prime Numbers Finder

Sep 21st, 2020 (edited)
954
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #This code will get a range of numbers and will find all the prime numbers in range
2. def number_range_function():
3. #this function takes in a range of numbers and converts it to a list of numbers.
4.     num_range=[]
5.     print("Input lower limit:")
6.     lower=int(input())
7.     print("Input upper limit:")
8.     upper=int(input())
9.     while upper>lower:
10.         num_range.append(lower)
11.         lower+=1
12.     num_range.append(lower)
13.
14.     print("The number range is:")
15.     print(num_range)
16.     print("-----------------------------------------------------------------------------------------------------------")
17.     return num_range
18.
19. def prime_finder(num_range):
20. #this function takes a list of numbers and converts them into 2 lists: 1st list contains all prime numbers in list of
21. #numbers and the 2nd list contains all the non-prime numbers in that list.
22.     num_check = 2
23.     prime=[]
24.     not_prime=[]
25.     print("CALCULATING...")
26.     for i in num_range:
27.         while num_check <= i:
28.             if i % num_check != 0:
29.                 num_check+=1
30.             elif num_check==i:
31.                 print("{} Is INDEED a prime number!".format(i))
32.                 prime.append(i)
33.                 num_check=2
34.                 break
35.             else:
36.                 print("{} Is NOT a prime number!".format(i))
37.                 not_prime.append(i)
38.                 num_check=2
39.                 break
40.     print("-----------------------------------------------------------------------------------------------------------")
41.     print("Prime Numbers Are (Total of {}):".format(len(prime)))
42.     print("{}".format(prime))
43.     print("Non-Prime Numbers Are (Total of {}):".format((len(not_prime))))
44.     print("{}".format(not_prime))
45.     return prime,not_prime
46.
47. number_range = number_range_function()
48. prime_finder(number_range)
RAW Paste Data