Write a python program that displays a message as follows for a given number: if it is a multiple of three, display "zip" if it is a multiple of five, display "zap". If it is a multiple of both three and five, display "zoom". If it does not satisfy any of the above given conditions, display "invalid".
Answers
Hello mate,
#Itsarya
# Define a function for printing particular messages
def display(Num):
if Num % 3 == 0 and Num % 5 == 0 :
print("Zoom")
elif Num % 3 == 0 :
print("Zip")
elif Num % 5 == 0 :
print("Zap")
else :
print("Invalid")
# Main code
if __name__ == "__main__" :
Num = 9
# Function call
display(Num)
Num = 10
display(Num)
Num = 15
display(Num)
Num = 19
display(Num)
#ItzRuleBreaker
Answer:
x=int(input("Enter the number"))
if x%3==0:
if x%5==0:
print("Zoom")
else:
print("Zip")
elif x%5==0:
print("Zap")
else:
print("Invalid")
Explanation:
now as per condn
if x is divisible by 3
then, if x is divisible by 5 too then printing zoom otherwise just Zip
now if x is divisible by 5 not by 3 then print Zap
and both case not valid then print Invalid
Hope it helps :-)