zoukankan      html  css  js  c++  java
  • python的第一个代码,写了2天。我的天呢

     简单购物车

    Commodity_list = [("Book", 80),
                      ("Clothes", 200),
                      ("Computer", 3000),
                      ("Fruit", 30),
                      ]
    shopping_cate = []
    salary = input("Input your money:")
    if salary.isdigit():
        salary = int(salary)
        while True:
            for index, item in enumerate(Commodity_list):
                print(index, item)
            choice_list = input('What to by?')
            if choice_list.isdigit():
                choice_list = int(choice_list)
                if choice_list <= len(Commodity_list) and choice_list >= 0:
                    Item = Commodity_list[choice_list]
                    if salary >= Item[1]:
                        shopping_cate.append(Item)
                        salary -= Item[1]
    
                        print("Add %s into your shopping cate,your blance is %d " %(Item,salary))
                    else:
    
                        print('Your not have blance!')
                else:
                    print('Input is wrong :')
    
            elif choice_list == 'q':
                print('----shopping cate-----')
                for i in shopping_cate:
                    print(i)
                print('Thank,you,for,your,patronage')
                exit()
  • 相关阅读:
    随手记
    boost::asio::udp 异步
    boost::asio::tcp 异步
    boost::asio::tcp 同步
    QML::MouseArea
    boost::concurrent::sync_queue
    std::chrono::时钟
    数据结构::队列
    数据结构::栈
    数据结构::线性表
  • 原文地址:https://www.cnblogs.com/Smalllv/p/8685960.html
Copyright © 2011-2022 走看看