Readme
(1) Job name: 1, three level menu; 2. Shopping Cart Program
(2) Job Requirements:
A: Level Three Menu
Data:
Menu = {
' Beijing ': {
' Haidian ': {
' Five crossing ': {
' Soho ': {},
' NetEase ': {},
' Google ': {}
},
' Zhongguancun ': {
' Iqiyi art ': {},
' Autohome ': {},
' Youku ': {},
},
' On the ground ': {
' Baidu ': {},
},
},
' Changping ': {
' Shahe ': {
' Old boy ': {},
' Beihang University ': {},
},
' Tian Tong Yuan ': {},
' Huilongguan ': {},
},
' Chaoyang ': {},
' Dongcheng ': {},
},
' Shanghai ': {
' Minhang ': {
"People's Square": {
' Fried Chicken Shop ': {}
}
},
' Zhabei ': {
' Train war ': {
' Ctrip ': {}
}
},
' Pudong ': {},
},
' Shandong ': {},
}
Demand:
You can select to go to each submenu in turn
Can go back from any level to the previous level
Can exit a program from any level
New knowledge points required: list, dictionary
B: Shopping Cart procedure
Data:
Goods =
[
{"Name":
"Computer", "Price": 1999},
{"Name":
"Mouse", "Price": 10},
{"Name":
"Yacht", "Price": 20},
{"Name":
"Beauty", "Price": 998},
......
]
Basic requirements:
1, after starting the program, enter the user name password, let the user enter the salary, and then print the product list
2. Allow users to purchase goods according to the product number
3, the user selects the goods, checks whether the balance is enough, enough on the direct debit, not enough on the reminder
4, can withdraw at any time, exit, print purchased goods and balance
5, in the user process, the key output, such as the balance, the product has been added to the shopping cart and other messages, need to highlight
Expansion requirements:
1, the user after the next login, enter the user name password, directly back to the last state, that is, the balance of the last consumption or those, re-login to continue to purchase
2, allow to query the previous consumption records
(3) Test:
Environment: Pycharm + WIN10 + python3x Interpreter
A, Level three menu:
Mainly in the Haidian---------five, the crossing of the order to test (the rest of Shanghai, Shandong data is not complete); halfway back to exit;
B, Shopping cart procedures
1, authentication login (abbreviated), direct write dead user name password, limit three times login;
2, Balance_file file record balance, initial login no data, prompt to enter the salary as the balance (log in directly to the file data as the balance), the exit program is written to the last balance
Balance_list list is used to store this login balance information
3, History_file file records historical consumption records, each successful purchase of goods after the product information is written to History_file
Shopping_car list is used to record this login shopping information, exit the program printing Shopping_car
Flow chart
A, Level three menu
Level three menu code:
B, Shopping cart procedures
Shopping Cart Program code:
python-level three menu and shopping cart program