Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def months_to_reach_target(principal, interest_rate_per_annum, target):
  2. interest_rate_per_month = (interest_rate_per_annum / 100) / 12
  3. num_months = 0
  4.  
  5. while principal < target
  6. # I think we can just reassign principal as python references are passed by assignment
  7. principal += principal * interest_rate_per_month
  8. num_month += 1
  9.  
  10. return num_months
  11.  
  12. print(months_to_reach_target(100, 10, 200))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement