This Python Program Displays All the Prime Numbers Between 1 to 100. Here prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Here is source code of the Python Program to Display All the Prime Numbers Between 1 to 100.
The program output is also shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
lower = 1 upper = 100 # uncomment the following lines to take input from the user #lower = int(input("Enter lower range: ")) #upper = int(input("Enter upper range: ")) print("Prime numbers between",lower,"and",upper,"are:") for num in range(lower,upper + 1): # prime numbers are greater than 1 if num > 1: for i in range(2,num): if (num % i) == 0: break else: print(num) |
Output: