Skip to content

Instantly share code, notes, and snippets.

@motionrus
Last active October 12, 2018 07:11
Show Gist options
  • Save motionrus/def83deb9f2609cadcf19d21c1b5c864 to your computer and use it in GitHub Desktop.
Save motionrus/def83deb9f2609cadcf19d21c1b5c864 to your computer and use it in GitHub Desktop.
# Простой пример: у вас родился ребенок, и вы начали инвестировать по 1500 рублей в месяц под 9% годовых.
# К восемнадцатилетию на его счету будет 817 000 рублей.
# А если класть эти деньги не на депозит, а вкладывать в более
# доходные инструменты, процентов под 15 годовых, то к совершеннолетию ваш
# ребенок получит 1 676 000. А начиналось все с 1500 рублей в месяц!
# Отлично подходит для накопления ребенку на будущее накопительное
def calculate_every_day(pay_in_month, count_years, percent_year):
# percent_year = 0.09 for example
pay_in_day = pay_in_month*12/365
count_days = count_years*365
percent_day = 1 + percent_year/365
sum = 0
for i in range(count_days):
sum = (sum + pay_in_day)*percent_day
return sum
def calculate_every_month(pay_in_month, count_years, percent_year):
# percent_year = 0.09 for example
sum = 0
percent_month = 1 + percent_year/12
for i in range(count_years*12):
sum = (sum + pay_in_month)*percent_month
return sum
def calculate_every_year(pay_in_month, count_year, percent_year):
# percent_year = 0.09 for example
sum = 0
percent_year += 1
for i in range(count_year):
sum = (sum + pay_in_month*12)*percent_year
return sum
print('Расчет процентов: "под 9% годовых"')
print('каждый день: "{:.2f}"'.format(calculate_every_day(1500, 18, 0.09)))
print('каждый месяц: "{:.2f}"'.format(calculate_every_month(1500, 18, 0.09)))
print('каждый год: "{:.2f}"'.format(calculate_every_year(1500, 18, 0.09)))
print('-----------------------------------')
print('Расчет процентов: "под 15% годовых"')
print('каждый день: "{:.2f}"'.format(calculate_every_day(1500, 18, 0.15)))
print('каждый месяц: "{:.2f}"'.format(calculate_every_month(1500, 18, 0.15)))
print('каждый год: "{:.2f}"'.format(calculate_every_year(1500, 18, 0.15)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment