I have two functions that calculate the balance after a year and the final balance after 'N' number of years (compound interest). Is there a more efficient way to do this/ way to do it with less code?
def balance_after_a_year(init_sum, interest_rate):
return init_sum * (100 + interest_rate) / 100
def final_balance(init_sum, interest_rate, years):
final_sum = init_sum
for i in range(years):
round_num = round(balance_after_a_year(final_sum, interest_rate), 2)
return round_num