This simple Python script calculates the projected value of an investment over time, taking into account an initial investment, regular monthly contributions, and an annual percentage yield (APY). It helps users estimate how their investment might grow year by year.
- Asks the user for:
- Initial investment amount
- Number of years to invest
- Monthly contribution amount
- Annual Percentage Yield (APY)
- Calculates compound growth with yearly compounding.
- Displays the final balance after the specified period.
- Python 3.7 or higher
- PyInputPlus module
Install dependencies with:
pip install pyinputplus-
Save the script as
investment_calculator.py. -
Open your terminal or command prompt.
-
Run the script with:
python investment_calculator.py
-
Follow the prompts to enter:
- Your initial investment
- The number of years to hold the investment
- How much you plan to invest monthly
- The APY (in percent)
Example session:
What is your initial investment? 1000
How many years will you hold your investment? 10
How much will you invest each month? 200
What is your APY(%)? 5
After 10 years, your account would be worth $29703.0.
- Interest compounds yearly.
- Monthly contributions are added annually (12×monthly amount).
- This script doesn’t account for taxes, fees, or inflation.
- For more precise models (e.g., monthly compounding), you can adjust the calculation loop.