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")
▶ RUN

Output/ Explanation:

Enter any Number : 10

10 is Composite Number


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

Enter any Number : 11

11 is Prime Number


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad