Home » Python » Python programs

Python program for Zip, Zap and Zoom game

Zip, zap and zoom python program: Here, we are going to implement a python program for zip, zap and zoom game.
Submitted by Ankit Rai, on June 05, 2019

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

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.