Answer to Question #335829 in Python for Dhea M. Maddela

Question #335829

Create a Python function that takes a number as a parameter and check the number is

PRIME or NOT.


I need the code to have an output stated above.


1
Expert's answer
2022-04-30T10:21:42-0400
def prime(num):
    if num > 1:
        for i in range(2, int(num/2)+1):
            if (num % i) == 0:
                print(num, "is not a prime number")
                break
        else:
            print(num, "is a prime number")
    else:
        print(num, "is not a prime number")


number = int(input("Enter number: "))
prime(number)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS