티스토리 뷰
오늘은 단리 이자 계산하는 코드를 만들었습니다.
적금을 이걸로 계산하면 됩니다.
단리 이자 계산 방법은 다음과 같아요.
납입금액 * 이율 * (개월수 * (개월수 + 1) / 2 / 12)
이건 이자에 대한 세금을 띤 금액 계산 법. ㅋㅋ
위에 나온 값 * (1 - 세금)
class InterestCompute:
def __init__(self):
self.amounts = None
self.term = None
self.rate = None
self.tax = None
def compute(self):
multiple = self.term * (self.term + 1) / 2 / 12
value = self.amounts * self.rate * multiple
return value * (1 - self.tax)
def to_string(self):
return "amount: {}, term: {}, rate: {}, tax: {}".format(self.amounts,
self.term,
self.rate,
self.tax)
compute = InterestCompute()
compute.amounts = 1000000
compute.term = 12
compute.rate = 0.04
compute.tax = 0.154
print (compute.compute())
print (compute.to_string())
compute에서 계산을 하게 되는데요. 잘보시면 위에 적어둔 공식이 나옵니다.
'Coding' 카테고리의 다른 글
Ruby. Gugudan (0) | 2020.08.30 |
---|---|
Python3. 구구단 (0) | 2020.08.30 |
Go. BinarySearch (0) | 2020.08.08 |
Go. 연속된 부분합 구하기 (0) | 2020.08.02 |
Go. 한글로 입력된 숫자를 더해서 한글로 출력하기 (0) | 2020.07.04 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- cocoapods
- git
- windows10
- Gradle
- MySQL
- Kotlin
- rxswift
- golang
- SWIFT
- CentOS
- war
- ubuntu
- nodejs
- Python
- github
- tomcat
- Codable
- centos8
- Java
- Linux
- docker
- Xcode
- Spring
- enum
- intellij
- php
- android
- ios
- Windows
- go
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함