Write Python code in MyCalc Class Define basic addition / subtraction / multiplication / division functions These
Fantastic news! We've Found the answer you've been seeking!
Question:
Write Python code
- in MyCalc Class
- Define basic addition / subtraction / multiplication / division functions
- These functions should update an internal variable as a running total/value calledans
- All functions must properly handle the math given standard math scenarios (i.e., show proper messages when trying to divide by zero for example)
- Since you'll likely be taking screenshots of the code, make sure you add a comment with your ucid and the date
- Define a "main" logic to run when the program runs
- This logic should ask for user input
- The input can be any valid number, any valid math operator, and any valid number (i.e., 2 * 2)
- This will do an immediate calculation, print it, and store the answer in theansvariable
- Alternatively, the input can beans, any valid math operator, any valid number (i.e.,ans* 2)
- 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
- The input can be any valid number, any valid math operator, and any valid number (i.e., 2 * 2)
- 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)
- Test number-add-number
- Test ans-add-number
- Test number-sub-number
- Test ans-sum-number
- Test number-mult-number
- Test ans-mult-number
- Test number-div-number
- Test ans-div-number
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date: