Question: Write Python code in MyCalc Class Define basic addition / subtraction / multiplication / division functions These functions should update an internal variable as a

Write Python code

  1. in MyCalc Class
  2. Define basic addition / subtraction / multiplication / division functions
    1. These functions should update an internal variable as a running total/value calledans
    2. All functions must properly handle the math given standard math scenarios (i.e., show proper messages when trying to divide by zero for example)
    3. Since you'll likely be taking screenshots of the code, make sure you add a comment with your ucid and the date
  3. Define a "main" logic to run when the program runs
  4. This logic should ask for user input
    1. The input can be any valid number, any valid math operator, and any valid number (i.e., 2 * 2)
      1. This will do an immediate calculation, print it, and store the answer in theansvariable
    2. Alternatively, the input can beans, any valid math operator, any valid number (i.e.,ans* 2)
      1. This will use the previous answer (or 0 if not set) as part of the calculation, print it, and will store the new answer in theansvariable
  5. make a test case for each scenario that utilize functions to have expected input and compare against expected output, all cases should pass (test cases should have a series of data passed into them)
    1. Test number-add-number
    2. Test ans-add-number
    3. Test number-sub-number
    4. Test ans-sum-number
    5. Test number-mult-number
    6. Test ans-mult-number
    7. Test number-div-number
    8. Test ans-div-number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the Python code that implements the requirements python class MyCalc def initself selfans 0 de... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!