Lab 2

Lab Description:

In this lab I basically used Python for create a program which perform the different operations (sum, difference, product, quotient, remainder, compare) with two integer numbers, and displays the result. For it I used a boolean expression with modulus and relational operators.  Also i used a while, if, elif, and else statements.

 

Code:

 
z=1
while z==1:
    z=input('Menu: (1)Enter (2)Exit ')
    print z
    if z==1:
        x=input('Enter x ')
        y=input ('Enter y ')
        x=int(x)
        y=int(y)
        print 'x+y =', x+y
        print 'x-y =', x-y
        print 'x*y =', x*y
        print 'x/y =', x/y
        print 'x%y =', x%y
        if x>y:
            print 'x>y'
            pass
        elif x<y:
            print 'x<y'
            pass
        else:
            print 'x=y'

 

lab2

 

 

 Screenshots:

 

lab2a

Leave a Reply

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