A Python script to determine if a given number is prime or not.
- Run the Python script in a console or terminal.
- Enter a number when prompted.
- The program will reveal whether the number is prime or not.
The script uses a basic algorithm to check for divisibility, iterating up to the entered number. If the number is not divisible by any number in this range, it's considered prime.
def prime_checker(number):
is_prime = True
for i in range(2, number):
if number % i == 0:
is_prime = False
if is_prime:
print(f"{number} is a prime number.")
else:
print(f"{number} is not a prime number.")
# Test the function with different numbers
input_user = int(input("Enter a number: "))
prime_checker(number=input_user)