-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
선생님 질문이 있습니다.
21.04.25 23:23 작성 조회수 98
1
commission, balance =withdraw_naght(blance,500)
print("수수료는 {0}원이며, 잔액은 {1}원 입니다.".format
(commission, balance))
수수료는 100원 이며 , 잔액은 400원 입니다. 라고 문구가 뜨는걸 볼수 있는데 출금 금액을 1000원 이라고 입력을 하니 잔액이 -100원이라고 뜨는데 수수료 포함하여 잔액이 부족할 경우 출금이 완료되지 않았습니다. 라는 문구를 어떻게 하면 만들어 낼수가 있나요 .. 아무리 해도 오류만 나고 만드는 방법을 모르겠습니다.
답변을 작성해보세요.
1
1
haon
2021.04.26
이렇게하면될것같습니다.
def open_account():
print("새로운 계좌가 생성되었습니다.")
def deposit(balance, money): #입금
print("입금이 완료되었습니다. 잔액은 {0} 원입니다.".format(balance + money))
return balance + money
def withdraw(balance, money): #출금
if balance >= money: # 잔액이 출금보다 많으면
print("출금이 완료되었습니다. 잔액은 {0} 원입니다.".format(balance - money))
else:
print("출금이 완료되지않았습니다. 잔액은 {0} 원입니다.".format(balance))
return balance
def withdraw_night(balance, money): #저녁에 출금
commission = 100 # 수수료 100원
return commission, balance - money - commission
balance = 0 # 잔액
balance = deposit(balance, 1000)
#balance = withdraw(balance, 2000)
#balance = withdraw(balance, 500)
commission, balance = withdraw_night(balance, 1000)
if balance > 0:
print("수수료 {0} 원이며, 잔액은 {1} 원입니다.".format(commission, balance))
else:
print("수수료는 {0} 원이며, 출금이 완료되지 않았습니다.".format(commission))
답변 2