deda
Deda의 데이터 디자인
deda
전체 방문자
오늘
어제
  • 분류 전체보기 (121)
    • Python (27)
      • Python 기초 (17)
      • Python 데이터분석 (10)
    • SQL (9)
    • Coding test (54)
      • Python 기초문제 (45)
      • LeetCode (9)
    • BigData (2)
    • ZeroBase (3)
    • UX (0)
    • Business Review (1)
    • 통계 & 수학 (17)
      • 통계학 (14)
      • 수학 (3)
    • 스터디 (6)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 부트캠프
  • 제로베이스
  • pandas
  • 프로그래밍
  • 함수
  • 데이터사이언티스트
  • 코딩
  • 릿코드
  • 모듈
  • 데이터분석
  • 통계
  • 데이터분석가
  • 파이썬
  • 기초수학
  • 미니콘다
  • 팩토리얼
  • 등차수열
  • 최소공배수
  • 군수열
  • 등비수열
  • 계차수열
  • 네카라쿠배
  • 계산기
  • BMI
  • 마이데이터
  • 소인수분해
  • matplotlib
  • SQL
  • 데이터엔지니어
  • 빅데이터

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
deda

Deda의 데이터 디자인

[함수] 단리, 복리 계산기
Coding test/Python 기초문제

[함수] 단리, 복리 계산기

2022. 4. 29. 09:26

🔍  문제

원금, 기간, 이자율 입력 시, 단리, 월복리, 연복리 출력

 

🗝 사용함수

format(n, ',') : 1000의 자리에서 ' , '           ex) 1,000

 

🖥  실행

def formN(n):
    return format(n, ',')

def simpleRate(m,n,r):
    totalMoney = 0  
    totalRateMoney = 0
    for i in range(n):
        totalRateMoney += m*r*0.01
    totalMoney = m + totalRateMoney
    print(f'단리: {formN(int(totalMoney))}원')

#월복리
def compoundRate(m,n,r):
    totalMoney = m
    monthRate = r*0.01/12
    month = n*12

    for i in range(month):
        totalMoney += totalMoney * monthRate   

    print(f'월복리: {formN(int(totalMoney))}원')

#연복리
def compoundRateYear(m,n,r):
    totalMoney = m
    yearRate = r*0.01

    for i in range(n):
        totalMoney += totalMoney * yearRate   

    print(f'연복리: {formN(int(totalMoney))}원')


depositMoney = int(input('예치금(원) 입력:'))
year = int(input('기간(년) 입력:'))
rate = int(input('원 이율(%) 입력:'))

print('='*30)
simpleRate(depositMoney, year, rate)
compoundRate(depositMoney, year, rate)
compoundRateYear(depositMoney, year, rate)
print('='*30)

 

 

📝 결과물

 

'Coding test > Python 기초문제' 카테고리의 다른 글

[모듈] 성적 패스 확인  (0) 2022.04.29
[함수] 등차수열, 등비수열 계산기  (0) 2022.04.29
[함수] 비행기 표 영수증  (0) 2022.04.28
[함수] 속도, 시간 계산기  (0) 2022.04.28
[함수] 계산기 만들기  (0) 2022.04.28
    'Coding test/Python 기초문제' 카테고리의 다른 글
    • [모듈] 성적 패스 확인
    • [함수] 등차수열, 등비수열 계산기
    • [함수] 비행기 표 영수증
    • [함수] 속도, 시간 계산기
    deda
    deda
    데이터 분석 / 파이썬 / UX / 정량리서치

    티스토리툴바