Python program to check number is prime or not


Python program to check whether the given number is prime or not

Write a Python program to accept a number from the user, and check whether the given number is a Prime Number or Not

Video Tutorial

What is the meaning of a Prime Number..?

A number is said to be prime if it is not divisible by any other number except by 1 and itself.

For Example:

2, 3, 5, 7, and so on are prime numbers

4, 6, 8, 10, 12, 15, and so on are not prime numbers

Source Code of Prime Number Program in Python

num = int (input("Enter the number: "))
flag = 0
for i in range(2, num):
    if (num % i == 0):
        flag = 1
if (flag == 0):
    print("The number is prime")
    print ("The number is not a prime")


Case 1:

Enter the number: 66

The number is not a prime

Case 2:

Enter the number: 67

The number is prime


This tutorial discusses how to write a Python program to verify a number is prime or not. If you like the tutorial share it with your friends. Like the Facebook page for regular updates and YouTube channel for video tutorials.

Leave a Comment

Your email address will not be published. Required fields are marked *