Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def months_to_reach_target(principal, interest_percentage_per_annum, target):
- """Returns months needed to reach investment goal."""
- initial_principal = 0
- interest_rate_per_annum = 0.10
- end_target = 0
- interest_rate_per_month = interest_rate_per_annum / 12
- principal = initial_principal
- num_months = 0
- while principal < target + initial_principal:
- increase = principal * interest_rate_per_month
- principal = principal + increase
- num_months += 1
- """ Test args"""
- print(months_to_reach_target(100, 10, 200))
- print(months_to_reach_target(100, 30, 130))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement