프로그래밍/Python

23. 전달값과 반환값

mimi04 2023. 5. 24. 13:04
def deposit(balance, money):     #입금
    print("입금이 완료 되었습니다. 잔액은 {0}원 입니다.".format(balance+money))
    return balance + money    #반환 

def withdraw(balance, money):  #출금
    if balance >= money:  #잔액이 출금할 돈 보다 많을 때
        print("출금이 완료 되었습니다. 잔액은 {0}원 입니다.".format(balance - money))
        return balance - money
    else:
        print("출금이 완료되지 않았습니다.잔액은 {0}원 입니다.".format(balance))
        return balance
balance = 0
balance = deposit(balance, 1000)   #입금이 완료 되었습니다. 잔액은 1000원 입니다.
balance = withdraw(balance, 500)   #출금이 완료 되었습니다. 잔액은 500원 입니다.
반응형