Example #1
0
def adding(method, a, b):
    obj_1 = Operation(a, b)
    if method == 'add':
        try:
            if a < 10 and b < 10:
                resp = obj_1.add()
                return str(resp)

            else:
                raise AddError("values are large")

        except AddError as v:
            return str(v)

    if method == 'sub':
        try:
            if a > b:
                resp = obj_1.sub()
                return str(resp)

            else:
                raise SubError("value of b is always lesser than a ")

        except SubError as v:
            return str(v)

    if method == 'mul':
        try:
            if a < 10 and b < 10:
                resp = obj_1.mul()
                return str(resp)

            else:
                raise MulError("values are large")

        except MulError as v:
            return str(v)

    if method == 'div':
        try:
            if b != 0:
                resp = obj_1.div()
                return str(resp)

            else:
                raise DivError("the value of b is non zero value")

        except DivError as v:
            return str(v)
Example #2
0
def adding(method,a,b):
        obj=Operation(a,b)
        if method=="add":
                try:
                        if a<10 and b<10 :
                                res=obj.add()
                                return str(res)
                        else:
                                raise adderror("more than 10 add will not performed")
                except adderror as e:
                      return str(e)
        if method=="sub":
                try:
                        if a>b:
                                res1=obj.sub()
                                return str(res1)
                        else:
                                raise suberror("b is greater") 
                except suberror as f:
                        return str(f)
        if method=="mul":
                try:
                        if a<10 and b<10 :
                                res2=obj.mul()
                                return str(res2)
                        else:
                                raise mulerror("more than 10 mutiplication is not possible")
                except mulerror as g:
                        return str(g)
        if method=="div":
                try:
                        if b!=0:
                                res2=obj.div()
                                return str(res2)
                        else:
                                raise diverror("provide b as non zero value")
                except diverror as h:
                        return str(h)