Lab # 2

Description

Lab #2 consisted of displaying a  menu to the user with the following options of entering a number and then exiting. Once the user chooses his number(s) all statements will be answered regarding the chosen numbers. After that it will continue for the user to keep on choosing numbers infinite times until they exit. When the user is done and wants to exit they press (2) and receive a dismissal message indicating the program is done.

Coding

dog = True
while dog == True:
    option = input('Welcome!(1)enter a number (2)exit')
    if (option==2):
            print 'Thank you, come again!'
            break
    if option==1 :
        x = input ('enter x')
        y = input ('enter y')
        j = x + y
        print ('x + y =',j)
        j = x - y
        print ('x - y =',j)
        j = x * y
        print ('x * y =',j)
        j = x / y
        print ('x / y =',j)
        j = x % y
        print ('x % y =',j)
        j = x > y
        print ('x > y =',j)
        if x > y :
            print ' x is greater than y '
        if x==y :
            print 'x is equal to y'
        if x < y :
            print ' x is less than y'

Screenshots

lab 2

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *