Lab 2

Description:
This is a program that asks the user to input two numbers (x and y) after they choose the first option. Once the two numbers have been entered, the program will display the sum, difference, product, quotient, remainder, and whether x is greater than or less than y.

Code:

option = 1
while option == 1:
    option = input ("Menu (1) Enter numbers (2) Exit")
    if (option == 1):
        x = input ("Enter x")
        y = input ("Enter y")
        s = x + y
        print "x + y = ", s
        d = x - y
        print "x - y = ", d
        p = x * y
        print "x * y = ", p
        q = x / y
        print "x / y = ", q
        r = x % y
        print "REMAINDER", r
        if x > y:
            print 'x is greater than y'
        else:
            print 'x is less than y'

Screenshot:
lab2

Leave a Reply

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