Python Program To Check Whether The Number Is Prime Or Non-Prime

Check Prime Number With Python

Algorithm To Finding Number Is Prime Or Non-Prime:

Step 1: Take the input from the User.

Now Write the Python Program To Check Whether The Number Is Prime Or Non-Prime:

# Taking the input from User
number = int(input("Enter The Number"))
if number > 1:
for i in range(2,int(number/2)):
if (number % i == 0):
print(number, "is Non-Prime Number")
break
else:
print(number,"is a Prime number")
# If the number is less than 1 it can't be Prime
else: print(number,"is not a Prime number")

Explanation Of Program:

Line 1: In the first line, we will take the input from the user by input() keyword and converting it to an integer data type, If the user inputs a float number than we want to convert that number to an integer.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bloggystacker

Bloggystacker

Bloggystacker is an educational site providing contents on Technology, Lifestyles, Development, Designing, Marketing, Style, Products and more.