2nd week Assignment 1

Source: Internet
Author: User
Tags save file

1. Optimize the shopping process, allow users to choose how many items to buy,

2. Allow multiple users to log in, the next time you log in, continue to purchase the last balance, you can recharge (each user has a separate save file)

3. Allow users to view previous purchase records (record to display the purchase time of the goods)

4. Product List grading display, such as:

First level menu:

1. Home Appliance Class

2. Clothing Category

3. Mobile Phone class

4. Car Class

...

Select one, Car class, enter 2nd floor

1. BMW X3 33333

2.Audi Q5 33333

3.Pasate 33335

4.Tesla Model_3 430000

5.Tesla Model S 888888

5. When displaying a purchased item, if there are duplicate items, do not print multiple lines, but display them on one line, as

ID p_name num Total_price

1. Teslamodels 2 3434343434

2. Coffe 2 60

3. Bike 1 700

###

Blog must be written

The Readme must be written

Flowchart must be painted

You must not copy.

Use file, DateTime module, JSON

#!/usr/bin/env python#-*-coding:utf-8-*-# __author__= "Liudong" product_list = {' Home appliance class ': [(' Le video tv ', 7000), (' Haier refrigerator ', 5000), (' Little swan Washing Machine ', 2000)], ' Clothing class ': [(' Blazer ', ' 8000 '), (' Casual jacket ', 2000 '), (' sportswear ', 800)], ' Mobile phone class ': [(' Iphone7 ', 7000), (' Xiaomi note ', 2000) , (' Huawei ', 1000)], ' Car class ': [(' Mercedes ml ', 800000 '), (' Tesla ', 700000), (' Audi Q7 ', 750000)]}def Purchase_pro (): Passshop_car = []we Lcom_msg= ' Welcome to shopping Home '. Center (+, '-') print (welcom_msg) for I in Range (3): username = input (' please input yo ur username:[q=quit] ') if username = = ' Q ': Exit () User_account = open (' User_info.txt ', ' R ') User_accou Nt_list = User_account.readlines () #print (user_account_list) for user_name in User_account_list: (user_infile , Pass_infile,amount_infile) =user_name.strip (' \ n '). Split () # Print (User_name.strip (' \ n '). Split ()) # user_name            _infile=user_name.strip (). Split () [0] # Print (user_name_infile) if username = = User_infile:j = 0 While J <3:password = input (' Please input your password: ') if password = = Pass_infile: Print (' Login successed!                    Have a happy shopping time! ')  While True:print (' 1. View purchase history \n2. Recharge \n3. Check the balance \n4. See cart \ n ') user_want=input (' What                Do you do? ')  Else:print (' Invalid username or password ... ') print (' This is the%d time (s) '% (j + 1)) J + = 1 else:print (' Forget password? Please send a mail to Administrator,bye ') User_account.close () exit () salary=input ("Input R Salary: ") if Salary.isdigit (): Salary=int (Salary) Else:exit (" Invalid data Type ... ")

2nd week Assignment 1

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.