Python program to check number is prime or not using function

775
Python program to check number is prime or not using function
def prime(num):
    if num > 1:
     for i in range(2, num//2): 
       if (num % i) == 0: 
        return False
    return True
#_____main_____ 
n=int(input("Please enter any number: "))
if prime(n):
    print(n,"is Prime")
else:
    print(n,"is not Prime")

   Output 1:
           Please enter any number: 5
           5 is Prime
   Output 2:
           Please enter any number: 57
           57 is not Prime

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

Python program to check number is prime or not using function program to check number is prime or not using function in python write a program to check number is prime or not using function in python program to check number is prime or not using function write a program to check number is prime or not using function write a Python program to check number is prime or not using function write a program to check whether a number is prime or not using function in python write a program to check whether a number is prime or not using function program to check prime or not using function Python program to check whether number is prime or not using function program to check number is prime or not given number is prime or not using function number is prime or not using function in python Python program to check given number is prime or not using function program to check given number is prime or not using function in python write a program to check given number is prime or not using function