Lab #3

I’ve invented a program in which a user is given a menu with operations to choose from. The user has computations of addition, subtraction, multiplication, division, remainder, and comparing of numbers. If the user chooses option 7, the program will prompt the user to kill the page and it will close the program.

Code:

option = True
while option:
        option = input("""
        Menu:
        1: Addition of Numbers
        2: Subtraction of Numbers
        3: Multiplication of Numbers
        4: Division of Numbers
        5: Remainder of Numbers
        6: Compare Numbers
        7: Exit
        
        Choose operation to perform: """)
        print option
        if option == 1:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x + y
                print "x + y = ", z
        elif option == 2:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x - y
                print "x - y = ", z
        elif option == 3:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x * y
                print "x * y = ", z
        elif option == 4:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x / y
                print "x / y = ", z
        elif option == 5:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x % y
                print "x % y = ", z
        elif option == 6:
                x = input("Enter x: ")
                y = input("Enter y: ")
                z = x > y
                print "x > y = ", z
        elif option == 7:
                exit()

lab3scr

Leave a Reply

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