Lab 2

Lab 2

Lab Description:

Lab 2 was the most tedious because we had to use a lot information from the book and from what we learned at class, but it was not the real problem, the problem was the understand how “if, elif, else” work because they come in a certain order. Anyway the code is going to be display for down here.

Code:

def main():
    while True:
        x = input('enter fist value?')
        x1 = float(x)
        y = input('enter second value?')
        y1= float (y)

        print ('press (1) for addition ')
        print ('press (2) for substraction')
        print ('press (3) for multiplication')
        print ('press (4) for division')
        print ('press (5) for reminder')
        print ('press (6) to check if the first value is less than, equal, or greater than the second value')
        c = input('select operation')
        if c == 1:
            print 'answer is =',x1+y1, 
        if c == 2:
            print  'answer is =',x1-y1,
        if c == 3:
            print 'answer is =',x1*y1,
        if c == 4:
            print 'answer is =',x1/y1,
        if c == 5:
            print 'answer is=',x1%y1,
        if c == 6:
            if x > y:
                print('first valueis more than the second value')
            if x < y:
                print('first value is less than the second value')
            if x == y:
                print('the first value and second are simillar')
if __name__ == "__main__":
    main()

Screen Shoots: