Responsive Ad Slot

Latest

latest

Brexit

Brexit

Football

Football

America

America

Tech

tech

Games

games

VIDEO

Videos

News By Picture

pictures

pe

No comments

  






No comments
User Rating

4.1 average based on 254 reviews.


5 star
150
4 star
63
3 star
15
2 star
6
1 star
20
No comments
# Python Program to Check Prime Number

# Function to check prime number
def is_prime(n):
    # If the number is less than 2, it is not prime
    if n < 2:
        return False
    # If the number is 2, it is prime
    elif n == 2:
        return True
    else:
        for i in range(2, int(n**(0.5))+1):
            if n % i == 0:
                return False
        return True

# Taking input from the user
num = int(input("Enter a number: "))

# Checking if the number is prime or not
if is_prime(num):
    print(num, "is a prime number.")
else:
    print(num, "is not a prime number.")

© all rights reserved
made with by templateszoo
X