Q. Write a Python function that takes a number as a parameter and checks whether the number is prime or not.
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))
there should be an 'else' statement... please revise this code...
ReplyDeleteNo, here return statement will work as else statement.
DeleteWhere is the output
ReplyDeleteThank you for correct and use able code.
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )