Lab 2


Lab Description:

This is Lab 2 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. First, I typed a program that displays a menu to me with the following options (1) enter a number (2) exit, and I also put a while loop so the menu can be display as many times as the user still enter option (1). Therefore, When I enter option 1, the program will ask me for two integer numbers x and y. Next, I define the value of X and Y so I can continue with the lab. Finally, I typed all the operations that were in the sheet of the exercise and I saw the results in the Python shell.


option = 1
while (option == 1):
    option = input ("menu : (1) enter numbers (2) exit") 
    #print "option selected", option 
    if (option == 1): 
        x= input ("enter x :") 
        Y= input ("enter y :") 
        print "value of x =", 2
        print "value of y =", 3 

        z = x + y 
        print "x + y =", z 

        z = x - y 
        print "x - y =", z 

        z = x * y 
        print "x * y =", z 

        z = x / y 
        print "x / y =", z 

        z = x % y 
        print "x % y =", z 

        if x < y: 
            print "x is less than y"

        elif x > y:
              print "x is greater than y"

            print "x and y are equal"

Screen Shot 2013-10-01 at 6.43.36 PM

Leave a Reply

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