"" " Shopping cart functionality: . A guide users to enter an amount . B to show users all of the goods c guide the operation of the user input is required of [add and delete billing cart quit]. D guides the user to select merchandise. E guides the user input required. purchased quantity . f Add to cart [container] g operation of the entire cycle, number of cycles of uncertainty. "" " DEF the Add (): Print (super_market) # supermarkets product list print (price_list) # commodity price table commodity = input ( "please input you need to add to your shopping basket:") # Please enter the article you need to add commodity_number = int (input ( "please input the number of commodity:")) # Please enter the article you need to add number user_market [commodity] = commodity_number # merchandise will be added to the user's cart super_market [commodity] - = commodity_number return DEF the Dell (): dell_name = input ( "please input you del name:") # remove trade names dell_number = int (input ( "please the number you del:")) # number of items removed user_market [dell_name] - = dell_number # the shopping cart of goods removed super_market [dell_name] + = dell_number # commodity after the supermarket back into the existing product number Print (user_market) return DEF looking (): Print (super_market) Print (user_market) return DEF Settlement (): = 0 amout Print (user_market) for Key in user_market: amout + = user_market [Key] * PRICE_LIST [Key] Print (amout) if amout > money_user: #如果总价高于所带的金额,退出循环 print("you money is not pay for,please take the full money!") return False def exit(): print("Thank you for your presence and welcome to come again next time!!") return False money_user = int(input("please user input your take money:")) super_market = {"apple":50,"watermelon":20,"nuddles":40,"drinks":30} price_list = {"apple":2,"watermelon":10,"nuddles":6,"drinks":3} user_market = {} while True: operation = int(input("please input your operation\n(1.add****2.del****3.looking****4.settlement****5.exit) :")) if operation == 1: add() elif operation ==2: dell() elif operation ==3: looking() elif operation ==4: settlement() if settlement() == False: break elif operation ==5: exit() if exit() == False: break