Programming Examples

Python program to check given number is composite number or not


Write a Python program to accept a integer number from user and check number is composite Number or not.

Composite number is a whole numbers that have on 1 or more than 1 factors excluding 1 and itself.  

Solution

num=int(input("Enter any Number : "))
count=0
for a in range(2,num):
    if num%a==0:
        count+=1
if count>=1:
    print(num, "is Composite Number")
else:
    print(num, "is Prime Number")
Output

Enter any Number : 10

10 is Composite Number


========================= 

Enter any Number : 11

11 is Prime Number


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad