Skip to content

Instantly share code, notes, and snippets.

@Foxonn
Last active March 8, 2025 17:18
Show Gist options
  • Save Foxonn/57804defc2d963751127896fd6a8c262 to your computer and use it in GitHub Desktop.
Save Foxonn/57804defc2d963751127896fd6a8c262 to your computer and use it in GitHub Desktop.
Расчета вклада с капитализацией процента
def calculate_deposit(
month: int,
iterations: int,
start: int,
interest_deposit: float,
) -> None:
"""
Расчет вклада с капитализацией процента. Пополнение вклада происходит после первой итерации
:param month: Срок вложения
:param iterations: Кол-во циклов
:param start: Стартовая сумма вклада
:param interest_deposit: Годовой процент по вкладу
:return:
"""
add = start * month # Стартовая сумма вклада на следующей итерации
accumulate = 0 # Итоговая сумма всех итерация
accumulate += start
msg = "iteration: {iteration} | accumulate: {accumulate:.3f}"
print(f"total month: {month * iterations} | {month=} | {iterations=} | {start=} | {interest_deposit=}")
for iter in range(1, iterations + 1):
if iter > 1:
accumulate += add
_ = msg.format(iteration=iter, accumulate=accumulate)
print(_ + f" | {add=}")
else:
print(msg.format(iteration=iter, accumulate=accumulate))
for p in range(1, month + 1):
payout = (accumulate * ((interest_deposit / 100) / 12))
accumulate += payout
_ = msg.format(iteration=iter, accumulate=accumulate)
print(_ + f" | month: {p} | payout: +{payout:.3f}")
calculate_deposit(month=12, iterations=3, start=70_000, interest_deposit=19.56)
print()
calculate_deposit(month=2, iterations=18, start=70_000, interest_deposit=21.18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment