u/Interested737

Help me my phyton code dosen't work propoerly and for sure isn't efficent

Hello, this is my first ever actual Python program, I want it to give Info about numbers.

Firstly I want to ask what do you think about the labeling that I've doen, someone told me it is a good practice.

First of all the programm prints (on every number that i checked) that it is not prime, the reason is that if prime number is divisble by prime number it says that it is not one, I don't know how to fix this.

I also don't know if this is the besgt way to do this, just writeing down a bunch of prime numbers and dividing the user number by them?

Thank you for your anwsers :-)

Here is the code:

user_number = 0 # The programm creates a value for the number, which will be inputed by the user


# Input section


print("----------Number Info----------\n")
user_number = input("Input a whole number, the programm will show you information about it:\n >") # Asks the user to input the number and saves it as user_number


print(f"\nYour number is {user_number}. Here is the info: \n")


# even or odd


if int(user_number) % 2 == 0: # % gives back the remainder after the devison, the program checks, if it is 0
    print("It is even") # If it is 0 it prints: It is even
else:
    print("It is odd") # If it isn't 0 it prints: It is odd


# prime or not


if int(user_number) % 2 == 0:   # Programm divides number by some prime numbers and chceks the remainder,
    print("Is is not prime")    # if it isn't divisble by any of them it prints that it is a prime number,
elif int(user_number) % 3 == 0: #otherwise it prints that it isn't one
    print("Is is not prime")
elif int(user_number) % 5 == 0:
    print("Is is not prime")
elif int(user_number) % 7 == 0:
    print("Is is not prime")
elif int(user_number) % 11 == 0:
    print("Is is not prime")
elif int(user_number) % 13 == 0:
    print("Is is not prime")
else:
    print("It is not prime")
reddit.com
u/Interested737 — 4 days ago