作业

b=0
gwc=[]
splx=input("请输入“手机”或“电器”:")
if splx=="手机":
    while True:
        sp={"小米":998,"魅族":1298}
        print(sp)
        a=input("购买完成输入Buy进入结算,继续购买请输入物品名称:")
        if a=="小米":
            a=int(sp["小米"])
            print("成功加入购物车!")
            a1="小米"
            b+=a
        elif a=="魅族":
            a=int(sp["魅族"])
            print("成功加入购物车!")
            a2="魅族"
            b+=a
        elif a=="Buy":
            print("购买的商品有:"+ a1 + " " + a2)
            print(b)
elif splx=="电器":
    while True:
        sp={"空调":2999,"冰箱":1298}
        print(sp)
        a=input("购买完成输入Buy进入结算,继续购买请输入物品名称:")
        if a=="空调":
            a=int(sp["空调"])
            print("成功加入购物车!")
            a1="空调"
            b+=a
        elif a=="冰箱":
            a=int(sp["冰箱"])
            print("成功加入购物车!")
            a2="冰箱"
            b+=a
        elif a=="Buy":
            print("购买的商品有:"+ a1 + " " + a2)
            print(b)

  

posted @ 2019-05-22 00:24  收藏家。  阅读(109)  评论(0编辑  收藏  举报