Wie verwende ich eine geometrische Sequenz mit einer Investition von 5000 und eine 5-prozentige Steigerung jedes Jahr des neuen Wertes? Ich habe alles versucht und ich kann die Antwort nicht richtig beantworten. Bitte helfenGeometrische Sequenz in Python
So Jahr: 0 = 5000
- 5512,5
- 5788,13
-Code bisher:
def calc_profits(principal, year):
INTREST_GROWTH = 0.05
for profits in range (1, year):
y = year
p = principal
profits = [p * (INTREST_GROWTH ** (y - 1)) for y in range(1, y + 1)]
print("{} {:.2f}".format(profits(year, principal)))
Welchen Code haben Sie bisher ausprobiert? – bouteillebleu
def calc_profits (principal, Jahr): INTREST_GROWTH = 0,05 für die Gewinne im Bereich (1, Jahr): y = Jahr p = Haupt Gewinne = float [p * (INTREST_GROWTH ** (y - 1)) für y im Bereich (1, INTREST_GROWTH + 1)] drucken ("{} {: .2f}". Format (Gewinne (Jahr, Prinzipal))) – Sarah
Bitte Code in Ihrer Frage aktualisieren. – kgangadhar