Input a number and check if the number is a prime or composite number Python Program


num = int(input("Enter any number : "))
if num > 1:
    for i in range(2, num):
        if (num % i) == 0:
            print(num, "is NOT a PRIME number, it is a COMPOSITE number")
        print(num, "is a PRIME number")
elif num == 0 or 1:
    print(num, "is a neither Prime NOR Composite number")





Enter any number : 5
(5, 'is a PRIME number')


Enter any number : 123
(123, 'is NOT a PRIME number, it is a COMPOSITE number')





By cbsepython

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved