Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a python program for the following. Define basic addition / subtraction / multiplication / division functions These functions should update an internal variable as

write a python program for the following.

Define basic addition / subtraction / multiplication / division functions These functions should update an internal variable as a running total/value called ans 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 the ans variable Alternatively, the input can be ans, 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 the ans variable Create 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions