当前位置: 代码迷 >> 综合 >> python模拟银行自助取款
  详细解决方案

python模拟银行自助取款

热度:95   发布时间:2024-02-26 22:18:05.0
# 卡号
card1="1001"
pwd1="123456"
ban1=10000card2="1002"
pwd2="123456"
ban2=10000card3="1003"
pwd3="123456"
ban3=10000
print("欢迎来到python银行!")
times=0
while True:card=input("请输入银行卡号!")pwd=input("请输入密码:")ban=0 # 余额if card==card1 and pwd==pwd1:ban=ban1elif card==card2 and pwd==pwd2:ban=ban2   elif card==card3 and pwd==pwd3:ban=ban3else:times=times+1if times>=3:print("您已经3次输入错误,请联系银行柜台!")breakelse:print("卡号或者密码输入错误,请重新输入!")continuewhile True:num=input("请输入要办理的业务:1.存款 2.取款 3.退卡")if num=="1":inje=float(input("请输入存款金额"))if inje<=0:print("存款金额请大于0!")else:ban=ban+injeprint("存款成功!存入:",inje,"余额:",ban)elif num=="2":outje=float(input("请输入取款金额:"))if outje>ban:print("余额不足!:")continueelse:ban=ban-outjeprint("取款成功!取出:",outje,"余额:",ban)elif num=="3":print("退卡成功")breakelse:print("输入错误!")continue         
  相关解决方案