Created
October 19, 2021 10:46
-
-
Save amberj/eba0f41be9d48c90351dedd06018439c to your computer and use it in GitHub Desktop.
Calculate interest earned and maturity amount for Recurring Deposit (RD) in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
monthly_installment = 30000 | |
# 36 means one installment every month for 3 years | |
number_of_installments = 36 | |
# Annual rate of interest | |
# e.g. 9.25% | |
r = 9.25 | |
# number of compounding periods per year | |
# | |
# monthly = 12 | |
# quarterly = 4 | |
# daily = 365 | |
# half_yearly = 2 | |
# yearly = 1 | |
n = 4 | |
# number of years | |
#t = 2.25 | |
# if r=9, then r_computed is 9/100 | |
r_computed = r/100.0 | |
count = 1 | |
final_maturity_amount = 0 | |
while count <= number_of_installments: | |
t = (number_of_installments - count)/12.0 | |
individual_maturity_amount = monthly_installment * ((1 + (r_computed/n))**(n*t)) | |
final_maturity_amount = final_maturity_amount + individual_maturity_amount | |
count = count + 1 | |
print("Final maturity amount:", final_maturity_amount) | |
print("Interest earned:", final_maturity_amount-(monthly_installment*number_of_installments)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment