Question: # Problem 2 # def retVariable(salary, save, growthRates): # TODO: Your code here. - salary: the amount of money you make each year. -

# Problem 2 #

def retVariable(salary, save, growthRates): # TODO: Your code here. """ - salary: the amount of money you make each year. - save: the percent of your salary to save in the investment account each year (an integer between 0 and 100). - growthRate: a list of the annual percent increases in your investment account (integers between 0 and 100). - return: a list of your retirement account value at the end of each year. """

def testRetVariable(): salary = 10000 save = 10 growthRates = [3, 4, 5, 0, 3] savingsRecord = retVariable(salary, save, growthRates) print (savingsRecord) # Output should have values close to: # [1000.0, 2040.0, 3142.0, 4142.0, 5266.2600000000002]

# TODO: Add more test cases here.

Objective:

Write a function, called retVariable, which takes three arguments: a salary (salary), a percentage of your salary to save (save), and a list of annual growth percentages on investments (growthRates). The length of the last argument defines the number of years you plan to work; growthRates[0] is the growth rate of the first year, growthRates[1] is the growth rate of the second year, etc. (Note that because the retirement funds initial value is 0, growthRates[0] is, in fact, irrelevant.) This function should return a list, whose values are the size of your retirement account at the end of each year. Complete the implementation of: def retVariable(salary, save, growthRates): Write your code in the appropriate place in the template a6_1.py. To test your function, run the test cases in the test function testRetVariable(). You should add additional test cases to this function to further test your code. Of course, once you retire you will want to be able to withdraw some amount of money each year for living expenses. You can use your previous code to get the size of your retirement fund when you stop working. Now we want to model how much you can withdraw to spend each year after retirement. Suppose that, after retirement, your retirement fund continues to grow according to a list of annual growth percentages on investments (growthRates), while your annual expenses are constant, called expenses. To see how your retirement fund will change after retirement, we can use the following chart, where we let F represent the size of the retirement fund at the time of retirement, and we let expenses represent the amount of money we withdraw in the first year to cover our living costs: End of year 1: F[0] = savings * (1 + 0.01 * growthRates[0]) expenses End of year 2: F[1] = F[0] * (1 + 0.01 * growthRates[1]) expenses End of year 3: F[2] = F[1] * (1 + 0.01 * growthRates[2]) expenses

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!