Python program to determine if a given number is prime or not

To determine if a given number is prime or not in Python, you can check if it's divisible by any number other than 1 and itself. Here's a Python program to do that:

def is_prime(number):

# Prime numbers are greater than 1

if number <= 1:

return False

# Check for factors from 2 to the square root of the number

for i in range(2, int(number**0.5) + 1):

if number % i == 0:

return False

return True

# Example usage:

input_number = int(input("Enter a number: "))

if is_prime(input_number):

print("The number is prime.")


print("The number is not prime.")


This program prompts the user to input a number, and then it checks if the number is prime or not using the `is_prime` function. The `is_prime` function returns `True` if the number is prime, and `False` otherwise.