##### ► Python program for prime number check

Steps followed:
1. take input from user and store in num variable
2. validate user input by converting to integer
3. check if number is 0 or 1, if yes print not prime and terminate. Else divide the number from all numbers from 3 to one less then the number, if any number gives remainder as zero - increase the count
4. If count is 0, the the number is prime else its not a prime number
5. print result

Program
``````#python program for prime number check

#getting input from user and storing in num variables
num=input("enter a number: ")

#validating user input
try:
num=int(num)
print("you have entered valid number")

i=2
count=0

#0 and 1 are not prime numbers
if num in (0,1):
print("%d is not a prime number"%(num))
else:
while i<num:
if num % i == 0:
count += 1
i += 1
else:
i += 1
#prime numbers are only divisble by 1 and the number itself
if count == 0:
print("%d is a prime number"%(num))
else:
print("%d is not a prime number"%(num))

except:
print("you have entered invalid number")``````

Output
``````enter a number: 135
you have entered valid number
135 is not a prime number

enter a number: 139
you have entered valid number
139 is a prime number

enter a number: counter
you have entered invalid number``````