Question: # Program name: Wk7_Jonathan_Delvalle.py # Student Name: Jonathan # Course: ENTD220 # Instructor: Robert Haluska # Date: 8/19/2020 # Copy Wrong: This is my work
# Program name: Wk7_Jonathan_Delvalle.py
# Student Name: Jonathan
# Course: ENTD220
# Instructor: Robert Haluska
# Date: 8/19/2020
# Copy Wrong: This is my work
# This program is a code of Functions for addition, subtraction, multiplication, and division
# This is an enhancement of previous weeks
def calculate():
try:
import Mylib
lowRange = float(input("Enter your lower range:"))
highRange = float(input("Enter your high range:"))
number1 = float(input('Enter your first number:'))
number2 = float(input('Enter your second number:'))
operation = str(input("Enter problem sting like this, N1,N2,Operator"))
lr = lowRange
hr = highRange
choices = ["1) Add two numbers", "2)Subtract two numbers", "3)Multiply two numbers", "4)Divide two numbers",
"5)Scalc", "6) All in one"]
print(choices)
user_choice = input("Enter a number for the operation")
calc1 = Mylib.Calc1()
res = {
'+': calc1.add(number1, number2),
'-': calc1.sub(number1, number2),
'*': calc1.mult(number1, number2),
'/': calc1.div(number1, number2)
}
except ValueError:
print("You must enter a number")
else:
if number1 >= lowRange and number2 <= highRange:
if user_choice == '1':
print(res['+'])
elif user_choice == '2':
print(res['-'])
elif user_choice == '3':
print(res['*'])
elif user_choice == '4':
try:
print(res['/'])
except ZeroDivisionError:
print("You cannot Divide by zero")
elif user_choice == '5':
import Mylib
print(calc1.scalc(operation))
elif user_choice == '6':
import Mylib
print(res, calc1.scalc(operation))
else:
import Mylib
print(calc1.isinrange(lr, hr, number1, number2))
again()
def again():
calc_again = str(input("Do you want to calculate again? Please type y for yes or n for no:"))
if calc_again == 'y':
calculate()
elif calc_again == 'n':
print("See you later")
else:
quit()
calculate()
# Program name: Mylib.py
# Student Name: Jonathan Delvalle
# Course: ENTD220
# Instructor: Robert Haluska
# Date: 8/9/2020
# Copy Wrong: This is my work
def add(number1, number2):
return number1+number2
def sub(number1, number2):
return number1-number2
def mult(number1, number2):
return number1*number2
def div(number1, number2):
try:
return number1/number2
except ZeroDivisionError:
print("Cannot divide by zero")
def scalc(operation):
#implement this (I am not sure what to do)
pass
def isinrange(lr, hr, number1, number2):
if ((number1>=lr) and (number2<=hr)):
return True
else:
return False
*********I ran the program and input theses numbers:*******
Enter your lower range:-100
Enter your high range:100
Enter your first number:100
Enter your second number:0
Enter problem sting like this, N1,N2,Operator100,0,/
['1) Add two numbers', '2)Subtract two numbers', '3)Multiply two numbers', '4)Divide two numbers', '5)Scalc', '6) All in one']
Enter a number for the operation4
********Once I get to this point I get the following error*********
************What is wrong with the code????*******
Traceback (most recent call last):
File "C:\Users\choco\OneDrive\Desktop\ENTD220\Wk7_Jonathan_Delvalle.py", line 71, in
calculate()
File "C:\Users\choco\OneDrive\Desktop\ENTD220\Wk7_Jonathan_Delvalle.py", line 27, in calculate
calc1 = Mylib.Calc1()
AttributeError: module 'Mylib' has no attribute 'Calc1'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
