Skip to content

Instantly share code, notes, and snippets.

@mohamedamjad
Created March 30, 2021 08:22
Show Gist options
  • Save mohamedamjad/a77f2006018b8e6bef38475084951f05 to your computer and use it in GitHub Desktop.
Save mohamedamjad/a77f2006018b8e6bef38475084951f05 to your computer and use it in GitHub Desktop.
calcul simplifié (probablement faux) d'un tableau d'amortissement
import sys
def annuite(interest_rate, years, capital):
return (capital * interest_rate)/(1 - (1+interest_rate)**-years)
def tableau_amortissement(years, capital, interest_rate):
a = float(format(annuite(interest_rate, years, capital), '.2f'))
capital_debut_periode = capital
print("Annuité du prêt: " + str(a))
for i in range(years):
ip = interest_rate * capital_debut_periode
capital_amorti = a - i
print("ANNEE N"+str(i+1)+":")
print("capital du en début de période: " + str(capital_debut_periode))
print("intérêts payés: "+ str(ip))
print("capital amorti: " + str(a - ip))
capital_debut_periode -= capital_amorti
print(sys.argv)
years = int(sys.argv[1])
capital = float(sys.argv[2])
interest_rate = float(sys.argv[3])
tableau_amortissement(years, capital, interest_rate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment