to buy Id:2 ----------------------------- thePlease select another product, your current balance is: 1381 - Enter Q to exit the shoppingWuyi---------------------------- thePlease enter the item you want to buy Id:4 ----------------------------- Wu added success!!! -Your current balance is: 1315 About---------------------------- $ Please enter the item you want to buy Id:q ----------------------------- -Your current balance is: 1315 - you have the following items in your
data is saved is the account key corresponding to the shopping time value, this value is decoded from the JSON inside the dictionary # from JSON to Python recognizable dictionary data decoding process by the _load_database function to complete the return data# defines a function _get_shopping_history to query the shopping history def _get_shopping_history (accou
("-----------------") Print("You have chose"+p_item[0])Print("Your Balance:"+str (saving))Print("-----------------") Else: Print("Non existent") elifChoice = ='Q': Print("---------------") Print("You have chose the following goods:") Print("Goods\t\tnumber\tprice") Num= 1#Loop through the goods in the shopping cart, the
Directly on Demand:Shopping Cart ProcedureDemandAfter you start the program, let the user enter the payroll, and then print the list of itemsAllow users to purchase items based on their product numberAfter the user selects the product, checks whether the balance is sufficient, enough on the direct debit, not enough to remindYou can exit at any time, and when you exit, print the purchased goods and balancesA relatively simple program, using a list of o
payElsePrint ("Your balance is:", salary, ", Can't Buy:", list[choice][' name '])ElsePrint ("The item you entered does not exist, please re-enter ...")Continue# If you enter a value of w/w, go to checkout cartelif Choice = = ' W ' or choice = = ' W ':If Shoppcar:Print ("The item you have purchased:")Print ("---------------")For I in Shoppcar:Print (I[0])Print ("---------------")Print (">>> you now have a total surplus:", salary)BreakElsePrint (' * * * pro! You have not purchased a product to ex
); Else: #determine whether the product price combination of the user's choice is greater than the balance; if(SUM (Userselectprice) >Money ):Print("Sorry, your balance is not enough! If you want to buy", Userproducts,"also need to recharge", (SUM (userselectprice)-Money )); #If a product addition fails, the item that was last added to the user price list is deleted;Userselectprice.pop (-1); Else: #Add a product to a user's
ifMoney_of_guest ]: - Print("your balance is not sufficient to purchase this item, please select another item or enter Q to exit") - Else: - Print("added {name_of_product} to your shopping cart". Format (name_of_product=list_of_product[num_product][0])) -Money_of_guest = money_of_guest-list_of_product[num_product][1] - Print("your bala
= Input ("How many dollars this recharge:") User_add_money (name, Inp_money)defExit_sys (): Exit ('Exit Program') F= Open ("User.txt","r+") User_info=eval (f.read ()) Username= Input ("Please enter your user name:") Password= Input ("Please enter your password:")ifUsername not inchUser_info:Print("the user name is not correct, please try again")Else: ifPassword = = user_info[username]["Password"]: Print("Welcome"+ Username +"Log in to the shopping
, the number of shopping options, etc., to be optimized9. When exiting the program, save the newly generated user information to the user dictionary file.The first time you need to write the dictionary content to a file:#-*-coding:utf-8-*-importpickleuser_list={ ' Test1 ':{ ' username ': ' test1 ', ' userpasswd ': ' 123456 ', ' salary ': ', ' Shop_car ': ', ' shop_ Car_list ': ' }, ' Test ':{ ' username ': ' Test ', ' USERPASSWD ': ' ABCD ', ' sala
Program: Shopping Cart ProgramDemand:
After you start the program, let the user enter the payroll, and then print the list of items
Allow users to purchase items based on their product number
After the user selects the product, checks whether the balance is enough, enough on the direct debit, enough to remind
You can exit at any time to print the purchased goods and balances when exitin
Program Exercise: Shopping Cart ProgramRequirements:1. After starting the program, let the user enter the payroll and then print the list of items2. Allow users to purchase items based on their product number3. After the user selects the product, checks whether the balance is enough, enough on the direct debit, enough to remind4. Can exit at any time, when you exit, print purchased goods and balances#商品清单pr
#coding Utf-8#1, design a shopping cart program, prompting the user to enter wages, pay input after opening the product list, prompting the user to select the product to buy#2, select a product, if the balance is sufficient, the purchase succeeds, and the product list is printed, otherwise the purchase fails, showing the balanceSalary=int (Input ("Please enter your salary limit:"))goodslist=[[' Sony color T
Program: Shopping Cart ProgramDemand:
After you start the program, let the user enter the payroll, and then print the list of items
Allow users to purchase items based on their product number
After the user selects the product, checks whether the balance is enough, enough on the direct debit, enough to remind
You can exit at any time to print the purchased goods and balances when exitin
1 #Author:johnson2 3 #After you start the program, let the user enter the payroll, and then print the list of business ports4 #allows users to buy items based on their product number, put them into a shopping cart, and use wages minus the price of the commodity. 5 #Press the Q key to exit the program and output the selected goods and payroll balances. 6sp_list=[7('Apple Phone', 5800),8('Notebooks', 6000),9(
Python Shopping Cart ProgramData structure: goods = [{"Name": "Computer", "Price": 1999},{"name": "Mouse", "Price": 10},{"name": "Yacht", "Price": 20},{"name": "Beauty", "price" : 998},......] Functional Requirements: Basic requirements: 1, after the start of the program, enter the user name password, let the user enter the salary, and then print the Product List
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.