Python 3 Script to Check Whether a Number given by User is Prime or Not Full Tutorial For Beginners

You are currently viewing Python 3 Script to Check Whether a Number given by User is Prime or Not Full Tutorial For Beginners

 

Welcome folks today in this post we will be checking if a number is prime or not in python. All the source code of the application is given as below.

 

 

 

Get Started

 

 

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

 

app.py

 

 

 

 

So now just run the below script to execute it

 

python app.py

 

 

As you can see 407 number is not prime as prime numbers are those numbers which are only divisible  by 1 or by itself.

 

You can also take the number as the input from the user as shown below in the script

 

app.py

 

 

 

 

 

 

This time we have taken the number from the user as command line input and you can see 23 is a prime number

 

Leave a Reply