Write a python function to check user provided number is prime or not and print the result


Topic: Write a python function to check user provided number is prime or not and print the result

Solution

def primeornot(num):
    if num > 1:
        for i in range(2,num):
            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")
primeornot(7)                



List all Python Programs