VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • python基础教程之my购物车

sum=0
a=input("请输入“水果”或“衣服”:")
if a=="手机":
    while True:
        shop = { '蓝葡萄',  '水蜜桃',  '草莓'}
        print(shop)
        a = input("输入Buy进入结算,继续购买请输入物品名称:")
        if a == "蓝葡萄":
            a = int(shop["蓝葡萄"])
            sum += a
        elif a == "水蜜桃":
            a = int(shop["水蜜桃"])
            sum += a
        elif a == "草莓":
            a = int(shop["草莓"])
            sum += a
        elif a == "Buy":
            print(sum)
        else:
            print("输入有误!!!,请重新输入:")
elif a=="衣服":
    while True:
        shop = {'短裤':59,  '上衣':32, '衬衫':66}
        print(shop)
        a = input("输入Buy进入结算,继续购买请输入物品名称:")
        if a == "短裤":
            a = int(shop["短裤"])
            sum += a
        elif a == "上衣":
            a = int(shop["上衣"])
            sum += a
        elif a == "衬衫":
            a = int(shop["衬衫"])
            sum += a
        elif a == "Buy":
            print(sum)
        else:
            print("输入有误!!!,请重新输入:")
else:
    print ("输入有误!!!,请重新输入:")



 

相关教程