Lab 3: Expanding my python knowledge

In this lab I expand on what I have learned and used all the elements in a single program.

 

def add(x, y):
    a = x+y
    return a
def subtract (x, y):
    b = x-y
    return b
def multiply (x, y):
   c = x*y
   return c
def divide(x, y):
    d = x/y
    return d
def remainder(x, y):
    e = x%y
    return e
option = 1
while option > 0 and option < 7:
    option = input ("What would you like to do? 1 Add 2 Subtract 3 Multiply 4 Divivde 5 Find Remainder 6 Compare 7 Exit")
    if option == 1:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        print add(x, y)
    elif option == 2:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        print subtract(x, y)
    elif option == 3:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        print multiply(x ,y)
    elif option == 4:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        print divide(x, y)
    elif option == 5:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        print remainder(x, y)
    elif option == 6:
        x = input ("Select value of x ")
        y = input ("Select value of y ")
        if xy:
            print ("X is greater than Y")
        else:
            print ("X is equal to Y")

Lab 3

Leave a Reply

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