Description

For this laboratory we created a menu with conditions where the person is able to choose between following or exiting  the program. As shown, the menu has two options ” Enter a Number” or “Exit” the program. We created a condition where if the person chose to “Enter a Number” it would enter a loop and ask the person to choose a number of preference for the value of X and Y, and in order to do this we had to use a command called input. Followed by that, we enter the different operations like addition , subtraction, multiplication, division, the remainder, and also compare the X and Y values determining whether X was greater, less or equal to Y. For the comparison we had to use certain conditions and applied commands like “if”, “elif”, and “else.” After the results showed up all at once, the program goes back to the menu, and asks the person to choose between the two options once again. If the person’s choice is one again, the program will repeat all over again, asking you for new values, comparing them, and giving you new results, but if the choice was two the program will exit. In order to exit the program and do not have an infinite loop the use of  an “else” condition was utilized and was follow by a “break” which means, that after option two is selected, the program should exit.

Code:

a = 1
while a == 1:
    a = input (“Menu \n (1) Enter a Number \n (2) Exit\n”)
    if a == 1 :
        x = input (“Enter a value for X: \n”)
        y = input (“Enter a value for Y: \n”)
        sum1 = x+y
        subs = x-y
        mult = x*y
        div = x/y
        rema = x%y
        print ( “The sum is: ” ), sum1
        print ( “The difference is: “), subs
        print ( “The product is: “), mult
        print ( “The quotient is: “), div
        print ( “The remainder: “), rema
        if x>y:
            print ( “X is greater than Y” )
        elif x<y:
            print ( “X  is less than Y” )
        else:
            print ( “X is equal to Y” )


Screenshot: Screen Shot 2013-11-07 at 9.07.48 AM