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


Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad