# 112|PYTHON – Time Value of Money with Numpy

BYU Student Author: @Mike_Paulsin
Reviewers: @Erick_Sizilio, @Jonathan_Weston, @Mark
Estimated Time to Solve: 20 Minutes

We provide the solution to this challenge using:

Overview
Imagine you’re a financial advisor helping a client plan for retirement. Your client is concerned that they won’t have enough money saved up to retire comfortably, and they’re not sure how much they need to save each month to hit their retirement goal.

To help your client out, you decide to write a Python program that will take in their current age, retirement goal, and age of retirement, and calculate how much money they need to save each month to reach their retirement goal.

The program should take into account the time value of money and an appropriate interest rate to provide a realistic estimate of the required monthly savings. By running this python script, your client will have a clear idea of how much they need to save each month in order to retire comfortably at their desired age.

With your help, your client can feel more confident about their retirement plan and take the necessary steps to achieve their financial goals.

Instructions

1. If you haven’t already, install the “numpy_financial” package. You can do this using “pip install numpy_financial”
2. Import numpy_financial as npf
3. Prompt the user to enter their current age, retirement goal, retirement age, and current retirement savings
4. Calculate the number of years until retirement by subtracting the current age from the retirement age
5. Set the industry average interest rate to 5%
6. Use the npf.pmt() function from numpy to calculate the required monthly savings. The function takes the following parameters:
• rate: the interest rate per period
• nper: the total number of payment periods
• pv: the present value of the investment (in this case, the current retirement savings)
• fv: the future value of the investment (in this case, the retirement goal)
• when: specifies when the payment is made (in this case, ‘end’ because the payment is made at the end of each month)
7. Format the calculated monthly savings as a currency string
8. Output the result to the user, telling them how much they need to save each month to reach their retirement goal at the specified retirement age.

Solution