Q:

Python program for Zip, Zap and Zoom game

belongs to collection: Python basic programs

0

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".

Examples:

    Input:
    Num  = 9
    Output : Zip

    Input:
    Num = 10
    Output : Zap

    Input:
    Num = 15
    Output : Zoom

    Input:
    Num = 19
    Output: Invalid

All Answers

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

Code

# 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)

Output

Zip
Zap
Zoom
Invalid

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

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to convert temperature from Celsius... >>
<< Python program to define an empty function using p...