Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def months_to_reach_target(principal, interest_percentage_per_annum, target):
  2.     """Returns months needed to reach investment goal."""
  3. initial_principal = 0
  4. interest_rate_per_annum = 0.10
  5. end_target = 0
  6.  
  7. interest_rate_per_month = interest_rate_per_annum / 12
  8. principal = initial_principal
  9. num_months = 0
  10.  
  11. while principal < target + initial_principal:
  12.     increase = principal * interest_rate_per_month
  13.     principal = principal + increase
  14.     num_months += 1
  15.  
  16. """ Test args"""
  17. print(months_to_reach_target(100, 10, 200))
  18. print(months_to_reach_target(100, 30, 130))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement