Intro to Python: Exceptions
Description
Unformatted Attachment Preview
A simple calculator to accept two numbers and print the addition, subtraction,
multiplication and division of the two numbers.
You are required to store each input number in a separate variable.
Part 2
You are going to enhance the prior assignment by doing the
following:
1) Limit the input range from -100 to 100 for each input number
2) Prevent dividing by zero (Do not use try-except)
3) Instead of hard coding values from -100 to 100, let the user enter the
range
4) check to make sure that the lower range in < the higher range
5) Do not use single letter variables, use variables that are related to the
task.
Week 2
You are going to enhance the prior assignment by doing the
following:
1) Create a function for each math operation (add, div, mult, sub)
2) The application will run forever, you will ask the user to continue or not.
3) create a function IsinRange() to test a value between two ranges like
this;
Here is the spec in pseudo code
IsInRanhe(lr, hr, n) lr=low range
hr=high range
n=number
if n between ln and hn
return true
else
return false
Week 3
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 add(lower,higher):
add=float(higher+lower)
print(f”The Result of {higher}+{lower}={add}”)
def div(lower,higher):
if lower==0:
print(“Cannot divide by Zero.”)
else:
div=float(higher/lower)
print(f”The Result of {higher}/{lower}={div}”)
def mult(lower,higher):
mult=float(higher*lower)
print(f”The Result of {higher}*{lower}={mult}”)
def sub(lower,higher):
sub=float(higher-lower)
print(f”The Result of {higher}-{lower}={sub}”)
def IsinRange(lr,hr,n):
if n>lr and n
Purchase answer to see full
attachment
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."