[파이썬 중급] DAY12

김유미·2023년 6월 17일

Python

목록 보기
6/16

조건별 모듈 만들기 - 비행기 티켓

childPrice = 18000
infantPrice = 25000
adultPrice = 50000
exDiscount = 0.5

def fomatNumber(n):
    return format(n, ',')
def printReceipt(c1, c2, i1, i2, a1, a2):

    cp = c1 * childPrice
    cp_dc = int(c1 * childPrice * 0.5)
    print(f'유아 {c1}명 요금 : {fomatNumber(cp)}원')
    print(f'유아 할인 대상 {c2}명 요금 : {fomatNumber(cp_dc)}원')

    ip = i1 * infantPrice
    ip_dc = int(i1 * infantPrice * 0.5)
    print(f'소아 {i1}명 요금 : {fomatNumber(ip)}원')
    print(f'소아 할인 대상 {i2}명 요금 : {fomatNumber(ip_dc)}원')

    ap = a1 * adultPrice
    ap_dc = int(a1 * adultPrice * 0.5)
    print(f'성인 {a1}명 요금 : {fomatNumber(ap)}원')
    print(f'성인 할인 대상 {a2}명 요금 : {fomatNumber(ap_dc)}원')

    print(f'Total: {c1+c2+i1+i2+a1+a2}명')
    print(f'Total: {fomatNumber(cp+cp_dc+ip+ip_dc+ap+ap_dc)}원')


childCnt = int(input('유아 입력: '))
childDiscountCnt = int(input('할인대상 유아 입력: '))

infantCnt = int(input('소아 입력: '))
infantDiscountCnt = int(input('할인대상 소아 입력: '))

adultCnt = int(input('성인 입력: '))
adultDiscountCnt = int(input('할인대상 성인 입력: '))

printReceipt(childCnt, childDiscountCnt, infantCnt , infantDiscountCnt, adultCnt, adultDiscountCnt)

실행부

scores = []

def addScore(s):   #입력하는 함수
    scores.append(s)

def getScore():
    return scores

def getTotalScores():
    total = 0
    for s in scores:
        total += s
    return total

def getAvgScores():
    avg = getTotalScores() / len(scores)
    return avg
profile
시작의 즐거움

0개의 댓글