Python Questions
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!")
6 years ago
25
Purchase the answer to view it

- Assignment2.py
- 500 word research
- PROGRESSION II: Exercise #3 DUE: Wednesday 10/16/13 EXERCISE #2.3: involves ethnography, a genre of writing that uses fieldwork to provide a...
- Corporate Finance Study Guide.
- Computer science homework help
- UCR 1
- XCOM 200 Week 9 Final Project - Conflict Management PowerPoint
- CORPORATE GOVERNANCE AND ETHICS IN MANAGEMENT
- PHI 445 Week 2 - Assignment - Investment in South Africa Paper
- MGT 488 Week 3 - DQ 1 and DQ 2
- For Archmage