계산기

    [모듈] 물건 가격 계산기

    [모듈] 물건 가격 계산기

    🔍 문제 모듈을 만들고 호출하는 계산기. 할인율 : 1개 구매 시 : 5% / 2개 구매 시 : 10% / 3개 구매 시 : 15% / 4개 구매 시 : 20% / 5개 이상 : 25% 🗝 사용함수 len(): 메시지의 길이, 자료 구조의 길이 출력 ex) len('hello') = 5 / gs = [1, 3, 5] → len(gs) = 3 🖥 실행 1) 모듈 생성 def calculatorTotalPrice(gs): if len(gs) 0: print('='*20) print(f'할인율: {result[0]}%') print(f'합계: {result[1]}원') print('='*20) else: result = pc.calculatorTotalPrice(gs) cs 📝 결과물

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

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

    🔍 문제 원금, 기간, 이자율 입력 시, 단리, 월복리, 연복리 출력 🗝 사용함수 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 ran..