본문 바로가기

Web_Application/python

분기복리 + 추가불입



import locale

locale.setlocale( locale.LC_ALL, '' )

base = 36000000		#기본 금액
rate = 0.024		#금리
tax = 0.846			#세금
monthly_add = 300000	#월불입금
yearly_Add = 600000		#년불입금	
	
year = 15			#기간(년)
max_loop = year * 4 #분기

for month in range(0, max_loop):
    current_benefit = (base + monthly_add) * rate * tax
    base = (base + monthly_add) * (1 + rate * tax) 

    if month % 4 == 0:
        base = base + yearly_Add
        print("")

    amt = locale.currency(base, grouping=True )
    bf = locale.currency(current_benefit, grouping=True )
    bfm = locale.currency(current_benefit/4, grouping=True )

    print("idx : {0} | amt : {1} | bf : {2} | bfm : {3}".format(month, amt, bf, bfm))

변수는 적절히 수정하셔서 사용하시기 바랍니다.

python 3.6 에서 테스트 됐습니다.