Print a prime number using if else statement in python
user
sure, i'd be happy to help with that! here's an example of how you can print a prime number using an if-else statement in python:
```
# define a function that takes in a number and returns "prime" if it's prime, or "not prime" otherwise
def is_prime(n):
  if n < 2:
    return "not prime"
  for i in range(2, int(n ** 0.5) + 1):
    if n % i == 0:
      return "not prime"
  return "prime"

# test the function with a few examples
print(is_prime(2))  # prints "not prime"
print(is_prime(3))  # prints "prime"
print(is_prime(4))  # prints "not prime"
print(is_prime(5))  # prints "prime"
```
this function uses the principle of dividing the input number by each integer from 2 to the square root of the number, and if it finds any divisor, it returns "not prime". if it reaches the end of the loop without finding a divisor, it returns "prime".

please note that this is just one way to determine whether a number is prime or not, and there are other more efficient and optimized ways to do so.
assistant
Sure, I'd be happy to help with that! Here's an example of how you can print a prime number using an if-else statement in Python:
```
# Define a function that takes in a number and returns "prime" if it's prime, or "not prime" otherwise
def is_prime(n):
  if n < 2:
    return "not prime"
  for i in range(2, int(n ** 0.5) + 1):
    if n % i == 0:
      return "not prime"
  return "prime"

# Test the function with a few examples
print(is_prime(2))  # prints "not prime"
print(is_prime(3))  # prints "prime"
print(is_prime(4))  # prints "not prime"
print(is_prime(5))  # prints "prime"
```
This function uses the principle of dividing the input number by each integer from 2 to the square root of the number, and if it finds any divisor, it returns "not prime". If it reaches the end of the loop without finding a divisor, it returns "prime".

Please note that this is just one way to determine whether a number is prime or not, and there are other more efficient and optimized ways to do so.
assistant