def open_account(): # open_account 함수를 정의
print("새로운 계좌를 생성합니다.")
def deposit(balance, money): # deposit 함수를 정의
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
def withdraw_night(balance, money):
commission = 100
return commission, balance - money - commission
balance = 0 # 잔액
balance = deposit(balance,1000)
# balance = withdraw(balance, 2000)
commission, balance = withdraw_night(balance, 500)
print("수수료는 {0}원 이며, 잔액은 {1}입니다.".format(commission, balance))
출력
입금이 완료되었습니다. 잔액은 1000원 입니다
수수료는 100원 이며, 잔액은 400입니다.
'SW.AI 트랙 > python' 카테고리의 다른 글
[Python] 파이썬. 함수/키워드값 (0) | 2023.03.17 |
---|---|
[Python] 파이썬. 함수/기본값 (0) | 2023.03.17 |
[Python] 파이썬. range 함수 (0) | 2023.03.17 |
[Python] 파이썬 예제풀이. for, 택시 승객수 구하기 (0) | 2023.03.13 |
[Python] 파이썬 예제풀이. for, 인텍스의 값/길이/문자 바꾸기 (0) | 2023.03.13 |