Exercise:
import easygui as g
card1_num = "1001"
card1_pwd = "123456"
card1_money = 0
while True:
card = g.multpasswordbox("Please input card number and pin",title = "Banking System",fields = ("Card Number","PIN"))
money = 0
if card == [card1_num,card1_pwd]:
money = card1_money
g.msgbox("Login Successfully.",title = "Banking System")
while True:
operation = g.buttonbox("Please pick your operation", choices=("Deposit", "Withdraw", "Balance", "Quit"))
if operation == "Quit":
break
elif operation == "Deposit":
save_money = g.integerbox("Please how much will you deposit:", lowerbound=0, upperbound=1000000)
money = money + save_money
g.msgbox("Deposit successfully. Money deposit is " + str(save_money))
elif operation == "Withdraw":
get_money = g.integerbox("Please input how much will you withdraw.", lowerbound=0, upperbound=1000000)
if get_money > money:
g.msgbox("Sorry no enough balance. Operation failed.")
else:
money = money - get_money
g.msgbox("Withdraw successfully. Money withdrew is " + str(get_money))
elif operation == "Balance":
g.msgbox("Your balance is " + str(money))
else:
g.msgbox("Login failed. Please re-enter:",title = "Banking System")
continue
[…] |____Unit 23 break and continue| |____Unit 24 nested loop| |____Unit 25 Pycharm and turtle| |____Unit 26 mimic banking system I| |____Unit 27 mimic banking system II| |____Unit 28 Perpetual Calendar I| |____Unit 29 Perpetual […]