강의

멘토링

커뮤니티

Inflearn Community Q&A

hellobk12312808's profile image
hellobk12312808

asked

Free Python Tutorial (Basic) - Become a Developer in 6 Hours

Argument and Return Value

return값에 commission 쓰는 경우요

Written on

·

159

0

# 1.

def withdraw_night(balance,money): #저녁에 출금
    commission = 100 # 수수료 100원
    if balance >= money+commission:
        print("출금이 완료되었습니다. 잔액은 {0}원입니다.".format(balance-commission-money))
        return commission, balance - money - commission
    else:
        print("출금이 완료되지 않았습니다. 잔액은 {0}원입니다.".format(balance))
        return balance

if문 return값에는 commission이 꼭 들어가야하고, else문은 안들어가던데 이유가 뭔가요

if 조건식에 commission이 들어가서인가요? (money + commission)

# 2.

balance = 0 # 잔액
balance = deposit(balance,1000)
commission, balance = withdraw_night(balance,500)
print("수수료 {0} 원이며, 잔액은 {1} 원입니다.".format(commission,balance))

밑에 commission, balance = withdraw_night(balance,500) 에서

commission이 들어가는 이유가 뭔가요?

함수 def withdraw_night 에 commission 있는데

쓰는 이유를 모르겠어요 ㅠㅠ fomat에 들어간 commission 때문인가요?!

withdraw_night 함수에서 commission 100 을 가져올거라서 인가요?

강의 잘 듣고 있습니다 감사여!!

python

Answer 1

0

return 함수를 이해하셔야 할것 같네요. else 문에도 넣어도 됩니다. 근데 넣을 필요 없으니 안넣는겁니다. 

hellobk12312808's profile image
hellobk12312808

asked

Ask a question