# Python program to check prime number

A prime number is a natural number greater than one that has no positive divisors other than one and itself. In other words, a prime number is a number that cannot be evenly divided by any different number except one and the number itself.

For example, some prime numbers are:

``````2
3
5
7
11
13
17``````

Prime numbers have important mathematical properties and are used in various fields, including number theory, cryptography, and computer science. They play a crucial role in many algorithms and mathematical concepts.

## Sample Python program to check prime number

Here is a simple code to check whether the number entered by user is a Prime number or not.

``````def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True

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

if is_prime(num):
print(num, "is a prime number.")
else:
print(num, "is not a prime number.")``````

Python program to check prime numbers from a list

An updated Python code, extended to check whether each number entered is a prime number or not.

``````def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True

# Input from the user
num_list = input("Enter a list of numbers separated by spaces: ").split()
num_list = [int(num) for num in num_list]

for num in num_list:
if is_prime(num):
print(num, "is a prime number.")
else:
print(num, "is not a prime number.")``````