5. More Mathematics with Python
Activity 5.01: Calculating Your Retirement Plan Using Series
Solution:
Perform the following steps to complete this activity:
- First, we need to identify the input variables and note that the problem boils down to calculating the n-term of a geometric sequence with a common ratio (1 + interest) and scale factor for the annual salary.
annual_salaryand the percentage, contrib, of it is what we contribute toward our plan.current_balanceis the money that we have at year 0 and should be added to the total amount.annual_capis the maximum percentage that we can contribute; any input value beyond that should be equal tocontrib_cap.annual_salary_increasetells us how much we expect our salary to increase by per year.employer_matchgives us the percentage amount the employer contributes to the plan (typically, this is between 0.5 and 1). Lastly, the current age, the duration of the plan in years, the life expectancy in years, and any other...