Python Questions

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper HERE Order a Different Paper HERE

You are going to enhance the prior assignment by implementing exceptions 

*****  You need to tell me where you implemented the exception and why. *****

Show me 2 test cases that will trap the errors

def addition(n1,n2):

    return n1+n2

def subtraction(n1,n2):

    return n1-n2

def multiplication(n1,n2):

    return n1*n2

def division(n1,n2):

    return n1/n2

def IsInRange(lr,hr,n):

    return lr<n<hr

def main():

    low = int(input(“Enter your Lower range:”))

    high = int(input(“Enter your Higher range:”))

    num1 = int(input(“Enter your First number:”))

    num2 = int(input(“Enter your Second number:”))

    if IsInRange(low,high,num1) and IsInRange(low,high,num2):

        add = addition(num1,num2)

        sub = subtraction(num1,num2)

        mul = multiplication(num1,num2)

        

        print(“The result of” + str(num1)+”+”+str(num2)+”=”+str(add))

        print(“The result of” + str(num1)+”-“+str(num2)+”=”+str(add))

        print(“The result of” + str(num1)+”*”+str(num2)+”=”+str(add))

        if num2 != 0:

            div = division(num1 , num2)

            print(“The result of %d.0/%d.0=%d.0” % (num1, num2,div))

        else:

            print(“The result of %d.0/%d.0=%d.0″ % (num1, num2,div))

    else:

        multiline_str=”””

The input values are outside the input ranges.

Please check numbers and try again.

Thanks for using our calculator!

“””

        print(multiline_str)

        

while True:

    main()

    user= input(“Continue Looping Y/N:”)

    if user != “Y”:

        break

print(“Thanks for using our calculator!”)