立即学习:https://edu.csdn.net/course/play/27668/373271?utm_source=blogtoedu
#超市收银系统 pNum1="1001" pName1="苹果" pPrice1=5.0 pNum2="1002" pName2="梨子" pPrice2=4.0 pNum3="1003" pName3="香蕉" pPrice3=3.0 while 1==1: total=0 #保存某个客户商品总价 while 1==1: pNum=input("请输入商品编号:") #pCount=int(input("请输入商品数量")) pName="" pPrice=0 msg=0 if pNum==pNum1: pName=pName1 pPrice=pPrice1 elif pNum==pNum2: pName=pName2 pPrice=pPrice2 elif pNum==pNum3: pName=pName3 pPrice=pPrice3 else: print("没有此商品!") msg=1 if msg==0: pCount = int(input("请输入商品数量")) pAmount=round(pCount*pPrice,2) total = total+pAmount print("您购买的商品是:",pName,"数量:",pCount,"金额:",pCount*pPrice,"请付款!") choice=input("继续添加请输入1,结算清请输入2:") #if choice =="1": # continue if choice =="2": break else: continue print("商品总金额:",total,"请付款!") while 1==1: pay=float(input("请输入付款金额:")) if pay<total: print("付款金额不够") else: print("付款:",pay,"找零:",pay-total) break print("欢迎下次光临")