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원 입니다.
반응형
'Python' 카테고리의 다른 글
25. 가변인자 (0) | 2023.05.24 |
---|---|
24. 기본 (0) | 2023.05.24 |
22. 함수 (0) | 2023.05.24 |
21. 한 줄 for (0) | 2023.05.24 |
20. continue/ break (0) | 2023.05.24 |