W4 Exceptions 220
# Program name : # Student Name : # Course : ENTD220 # Instructor : # Date : 01/23/2020 # Description : Math calculator in python # Copy Wrong : This is my work 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:")) #cast to int, otherwise input return string num1 = int(input("Enter your first number:")) num2 = int(input("Enter your second number:")) #check if the first and second numbers are in range if IsInRange(low , high, num1) and IsInRange(low , high, num2): add = addition(num1 , num2) sub = subtraction(num1 , num2) mul = multiplication(num1 , num2) #use print formating, %d = double, %f = float, %s = string print("The result of %d+%d=%d" % (num1, num2, add)) print("The result of %d-%d=%d" % (num1, num2, sub)) print("The result of %d*%d=%d" % (num1, num2, mul)) if num2 != 0: div = division(num1 , num2) print("The result of %d/%d=%f" % (num1, num2, div)) else: print("The result of %d/%d=%s" % (num1, num2,"You cannot divide by Zero")) else: print("Please check the numbers and try again") while True: main() do = input("Continue Looping Y/N:") if do != "Y": break print("Thanks for using our calculator!")