Q:

Write a Python function that takes a number as a parameter and check the number is prime or not

0

Write a Python function that takes a number as a parameter and check the number is prime or not

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

 I have used python 3.7 compiler for debugging purpose.

def test_prime(num):
    if (num==1):
        return False
    elif (num==2):
        return True;
    else:
        for x in range(2, num):
            if(num % x==0):
                return False
        return True             
print(test_prime(167))

Result:

True

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python program to print the even numbers f... >>
<< Write a Python function that takes a list and retu...