Question
Answered step-by-step

# Hello, I need to enhance my last week assignment with the new...

Hello, I need to enhance my last week assignment with the new requirements. Can you please assist with the following assingment since I am lost? I am including the following:

1. Assignment Information
2. Last Week Assignment

Assignment Information:

Week 8 : Read / Write

Instructions

# This is the flower box and it should at the beginning of each assignment

# You must add comments to your  code

# Program name : Wk8_firstname_lastname.py

# Student Name :

# Course : ENTD220

# Instructor : My  instructor

# Date : Any Day

# Copy Wrong : This is my  work

You are going to enhance the prior assignment by doing the following

1) Add menu items to write to a file and to read from a file

2) Make a class w rfile() with two methods to write the results to a file, and to read

the results from a file.

3)Use the same output from last  assignment

Last Week Assignment:

# Lib.py Class

class Calculator:

def __init__(self, lr, hr, num1, num2):

self.lowRange = lr

self.highRange = hr

self.numOne = num1

self.numTwo = num2

# This function will check check to make sure that user input values fall within the user input range

def IsinRange(self):

if self.numOne < self.lowRange or self.numOne > self.highRange or self.numTwo < self.lowRange or self.numTwo > self.highRange:

return False

else:

return True

# These functions will be called to perform the math operations

def Add(self):

add = self.numOne + self.numTwo

return add

def Multiply(self):

multiply = self.numOne * self.numTwo

return multiply

def Divide(self):

try:

divide = self.numOne / self.numTwo

except ZeroDivisionError:

divide = print("Sorry, you can't divide by zero!")

return divide

def Subtract(self):

subtract = self.numOne - self.numTwo

return subtract

# This function will return the answer of the calculations of two numbers in the first and second position of a string, the operator is in the third position.

def scalc(self, p1):

response = 0

newString = p1

#newString=p1.split(",") # This will split one string into smaller strings wherever there is a comma

if p1[2] == "*":

response = newString[0] * newString[1]

elif p1[2] == "/":

try:

response = newString[0] / newString[1]

except ZeroDivisionError:

response = print("Sorry, you can't divide by zero!")

elif p1[2] == "+":

response = newString[0] + newString[1]

elif p1[2] == "-":

response = newString[0] - newString[1]

return response

if __name__ == "__main__":

calc = Calculator(1, 10, 5, 7)

print(calc.Add())

Main:

# Main

# This line will import all functions from a module, rather than calling each individual function.

from Lib import Calculator

# Loop for getting user inputs and outputting results from calculations. Will perform as many calculations as user requests

range = True

while (range):

i = True

while i == True: # This loop will continue to loop until it receives four acceptable values for the following variables.

try: # This exception block will catch the error if a user attempts to input something other than a number.

lowRange = float(input("Enter your low range number: "))

highRange = float(input("Enter your high range number: "))

numOne = float(input("Enter your first value for math operations: "))

numTwo = float(input("Enter your second value for math operations: "))

except ValueError:

print("Try again with a valid number.")

else:

i = False

calc = Calculator(lowRange, highRange, numOne, numTwo)

range = calc.IsinRange()

if range == False:

print("The input values are outside the ranges inputnPlease check your values and try again")

break

# Creating a menu for user to choose exactly which math function they want to perform.

res = True

while res == True:

selection = 0

print("Choose your math function:")

print("1: Addition n2: Subtraction n3: Multiplication n4: Division n5: All of the above n6: Stop calculations with these numbers")

try:

selection = int(input("Enter your selection here:"))

except ValueError:

print("Please try again with acceptable values")

finally:

print("You chose ", selection)

p1 = [numOne, numTwo]

plus = [numOne, numTwo, "+"]

minus = [numOne, numTwo, "-"]

multiply = [numOne, numTwo, "*"]

division = [numOne, numTwo, "/"]

print("Your first number is ", p1[0], "and your second number is ", p1[1])

if selection == 1:

print("The result of", numOne, "+", numTwo, "=", calc.scalc(plus))

elif selection == 2:

print("The result of", numOne, "-", numTwo, "=", calc.scalc(minus))

elif selection == 3:

print("The result of", numOne, "*", numTwo, "=", calc.scalc(multiply))

elif selection == 4:

print("The result of", numOne, "/", numTwo, "=", calc.scalc(division))

elif selection == 5:

p1Dict = {"plus":calc.scalc(plus), "minus":calc.scalc(minus), "multiply":calc.scalc(multiply), "divide":calc.scalc(division)}

print(numOne, "+", numTwo, "=", p1Dict["plus"])

print(numOne, "-", numTwo, "=", p1Dict["minus"])

print(numOne, "*", numTwo, "=", p1Dict["multiply"])

print(numOne, "/", numTwo, "=", p1Dict["divide"])

elif selection == 6:

break

else:

print("Please choose a nuber from the list.")

cont = input("Do you want to perform another calculation? Y/N ")

if cont == "N":

break

if cont == "Y":

continue

else:

break

print("Thank you for using my calculator")

Answer & Explanation
Solved by verified expert
Helpful
<p>risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus</p> Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

`inar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet,`

gue

gue

, dictum

`, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor si`

gue

gue

ec fac

`at, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus a`
Step-by-step explanation
1 Attachment
JPG
Student review
100% (1 rating)
Thorough explanation
Easy to follow
Clear formatting

"Excellent explanation and easy-to-understand formats. Thank you very much for your assistance."