Skip to main content

Welcome to Coding 4 Programming

Addition of Two Binary Numbers | Function | Python

To check Prime Number | Function | Python

Python Program to check whether entered Number is Prime or Not through Function.

    1. def primef(num):
    2.     if (num==1 or num==0):
    3.         return False
    4.     elif (num==2):
    5.         return True
    6.     else:
    7.         c=1
    8.         for i in range(2,num):
    9.             if(num%i!=0):
    10.                 c+=1
    11.         if(c==num-1):
    12.             return True
    13.         else:
    14.             return False
    15. n=int(input("Enter Number to check Prime="))
    16. print(primef(n))

Screenshot of above Program with Output.

Prime Number
Prime Number

Note:

  • If you have any problem related to this program. Please do comment your Problem or Mail us.
  • For illustrating the any concept you can comment by line number.
  • Thank you! For more programs do regular visit to Coding 4 Programming.

Comments

Popular Posts