Lab 3

Lab Description:

This is a program that people have options to choose the methods of the calculations.

Code:

option=1 
while option < 7:
    option = input("select and option: (1)Sum numbers(2)Subtract numbers(3)Multiply numbers(4)Divide numbers(5)Remainder of numbers numbers(6)Compare numbers(7)Exit")
    if (option ==7):
        exit
    if (option ==1):
        def addition(a,b):
            c=a+b
            print c
            return
        x=input ("enter value x")
        y= input ("enter value y")
        addition(x,y)
    if (option ==2):
        def subtraction(a,b):
            c=a-b
            print c
            return
        x=input ("enter value x")
        y= input ("enter value y")
        subtraction(x,y)
    if (option ==3):
        def multplication(a,b):
            c=a*b
            print c
            return
        x=input ("enter value x")
        y= input ("enter value y")
        multplication(x,y)
    if (option ==4):
        def division(a,b):
            c=a/b
            print c
            return
        x=input ("enter value x")
        y= input ("enter value y")
        division(x,y)
    if (option ==5):
        def remainder(a,b):
            c=a%b
            print c
            return
        x=input ("enter value x")
        y= input ("enter value y")
        remainder(x,y)
    elif (option ==6):
        def comparsion(a,b):
            if a < b:                 
                print 'x is less than y'             
            elif a > b:
                print 'x is greater than y'
            else: 
                print 'x and y are equal'
            return
        x=input ("enter value x")
        y= input ("enter value y")
        comparsion(x,y)

Screenshot:lab 3

Leave a Reply

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