Last active
October 19, 2021 10:44
-
-
Save amberj/3cfae3f07e38a549178816de063639ed to your computer and use it in GitHub Desktop.
Calculate interest earned and maturity amount for Fixed Deposit (FD) 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 | |
principal = 200000 | |
# 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 = 3 | |
# if r=9, then r_computed is 9/100 | |
r_computed = r/100.0 | |
maturity_amount = principal * ((1 + (r_computed/n))**(n*t)) | |
print(maturity_amount) | |
print("Final maturity amount:", maturity_amount) | |
print("Interest earned:", maturity_amount-(principal)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment