Question: For this assessment, you will write a function that for a given invested amount will return that amount plus the calculated investment gains. If the
For this assessment, you will write a function that for a given invested amount will return that amount plus the calculated investment gains. If the given amount is greater than the $ million threshold, the app will need to increase the rate of return for every million dollars invested plus the original rate of Finally, you will implement the functionality to estimate forecast the return on investment over a time period.
In order for you to start this project, we will provide a function template that can be followed to solve this challenge. The code block below is a sample way that this project could be structured.
# global variable def calculategainsamountinv: Calculating the return gains of an investment. # base amount gain margin if amountinv : # check whether the invested amount is greater than the multiplier amount # gather the value of the division # update the gainmargin by the multiplier mod # calculate the total amount of gains # calculate the total amount plus the gain margin # return the gains, the full amount and the gain margin
Create a userdefined function called calculategains which receives the amount desired to be invested. Outside this function, create a global variable, multiplieramount that would be accessible at any point in your code to store the "multiplier amount", which will be the amount that would trigger the increase on the gain margin in case the invested amount is greater than this value. In our case, this amount is set to million.
Inside your function, create a variable to store the gain margin, which is by default. Also create variables for totalgains and totalamount, setting default values to After these declarations, the first thing to check is whether the amount invested is greater than one thousand which is the minimum application value to start using the app.
Next, check if the amount is greater than the multiplier value million If it is greater, then update the gain margin variable with the new gain margin and add the estimated amount to the original amount, otherwise just multiply the values to obtain the return on investment for the given amount.
Finally, you need to return the total gains amount, the amount invested updated with the return on investment added to it as well as the gain margin the ordering is important for testing purposes To test your function, enter the following amount: $ million
To summarize:
In the userdefined function declare a global variable inside the python file to store the multiplier amount.
Declare a variable to store the gain margin.
Declare variables to store the total gains and the total amount.
Check if the amount is greater than the minimum value which is
Check if the amount is greater than the multiplier amount which is
If so update the gain margin.
Calculate the total gains by multiplying the gain margin by the amount.
Return the total gains, total updated amount, and gain margin.
Example:
Input : calculategainsamountinv
Output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
