学习笔记(39):玩转Python-Python3基础入门-案例-升级超市收银

这篇学习笔记详细介绍了如何使用Python3构建一个超市收银系统,涵盖了基础语法、函数应用以及面向对象编程的概念,通过实际案例帮助读者深入理解Python编程。
摘要由CSDN通过智能技术生成

立即学习: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("欢迎下次光临")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值