Q. Write a function that takes one argument and report if the argument is prime or not. write a program that invokes this function.
Answer :-
def prime(a): for i in range (2,a) : if a % i == 0 : return "This is not prime number" return "Prime number" a = int(input("Enter a number :- ")) print(prime(a))
Output:-
Enter a number :- 0
Prime number
>>>
Enter a number :- 40
This is not prime number
>>>
Enter a number :- 2
Prime number
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )