Lab 3

Lab Description:

This is Lab 3 and I utilized the program call Python 2.6.6, which is a programming language. I used the tool call Idle to type expressions, statements or variables in the Python shell, which is where you type and if you want to check your results you go to the Python interpreter where you type a code and run it to get the results in the Python shell. I set up all the functions so that when you run the program all the functions have to appear showing a menu of which one do you want to choose. After that , I set up x and y , so the user can enter any number that he/she wants in order to use the functions.


def xy1(x,y):
    return x + y
def xy2(x,y):
    return x - y
def xy3(x,y):
    return x * y
def xy4(x,y):
    return x / y
def xy5(x,y):
    return x % y

x = float(input("Enter the value of x:"))
y = float(input("Enter the value of y:"))

print "1- Sum numbers"
print "2- Subtract numbers"
print "3- Multiply numbers"
print "4- Divide numbers"
print "5- Remainder of numbers"
print "6- Compare numbers"
print "7- Exit"

selection = input("choose the option that you want to use:")

if selection ==1:
    print "The sum of", x,"and", y, "is", xy1(x,y)

elif selection ==2:
    print "The diffrence of", x,"and", y,"is", xy2(x,y)

elif selection ==3:
    print "The product of", x,"and", y,"is", xy3(x,y)

elif selection ==4:
    print "The quotient of", x,"and", y,"is", xy4(x,y)

elif selection ==5:
    print "The remainder of", x,"and", y,"is", xy5(x,y)

elif selection ==6:
    if x < y:         print x, "is less than", y     elif x == y:         print x, "is equal to", y     elif x > y:
        print x, "is greater than", y


Screen Shot 2013-11-06 at 10.48.07 PM

Leave a Reply

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