Python 3 Script to Find Prime Numbers From a Given Range of Numbers Full Tutorial For Beginners

Python 3 Script to Find Prime Numbers From a Given Range of Numbers Full Tutorial For Beginners

 

Welcome folks today in this post we will be finding prime numbers in the given range of numbers that is given by user in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py  file and copy paste the following code

 

See also  Python 3 Gmail API Example to Fetch Recently Sent Emails Using Imaplib Library Full Project For Beginners

app.py

 

 

# To take input from the user
start= int(input("Enter start number of Range: "))
end = int(input("Enter end number of Range"))
  
for i in range(start, end+1): 
  if i>1: 
    for j in range(2,i): 
        if(i % j==0): 
            break
    else: 
        print(i)

 

 

As you can see we are taking the start number of the range and the end number of the range from the user where to find the prime numbers. Now if you execute the python script by typing the below commnad

See also  Python 3 Script to Build Snake Water Gun Game in Command Line Full Project For Beginners

 

python app.py

 

 

As you can see there are four prime numbers between 12 and 24 which are 13 17 19 and 23

Leave a Reply