Python Self-study Road _ Shopping Cart Program

Source: Internet
Author: User

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('Coffee', 60),Ten('Book', 80), One('Tea', 10) A ] -Gwc=[] -Gz=input ("Please enter your salary:") the ifgz.isdigit (): -gz=Int (GZ) - Else: -     Print("Enter a salary error. ") + exit () -  forIinchsp_list: +     Print(Sp_list.index (i), i) A  whileTrue: atShuanze=input ("Enter the product number you want to select:") -     ifshuanze.isdigit (): -Shuanze=Int (Shuanze) -         ifShuanze < Len (sp_list) andshuanze>=0: -s_item=Sp_list[shuanze] -             ifs_item[1]<=GZ: in gwc.append (S_item) -Gz-=s_item[1] to                 Print("you have selected the product%s, and you have%s dollars left."%(S_ITEM,GZ)) +             Else: -                 Print("There is not enough pay. ") the         Else: *             Print("the item entered does not exist. ") $     elifshuanze=='Q':Panax Notoginseng          forIinchGWC: -             Print(i) the         Print("you still have%s dollars left"%(GZ)) + exit () A     Else: the         Print("Please enter a number")

Python Self-study Road _ Shopping Cart Program

Related Article

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.