this example for everyone to share the program: Python shopping cart program, the specific content of the following

requirements:

  • startup, the user input salary, and then print commodity list
  • allow users to purchase commodity
  • user selection goods according to the commodity number, check the balance is enough, Enough to directly withhold money, not enough to remind
  • can withdraw at any time, when exit, print already purchased goods and balance
  • if the balance is insufficient, can recharge the

Code:

 #coding=utf-8 #Version:python 3.6.0 Ng'salary = int (input ("Please input your salary:")) shoppingmart = [] items = (["1", "Huawei", "RMB", 2800], "2", "RMB", "3", "RMB" = ` ` ` 1.' 28002. cents 3003. 80 - -- - -- - --- - -- " '' 'Print (msg_items) while True: shopindex = int (input ("Please choose goods:")) if salary. Alance is: ", salary) decision = input (" Do you want to quit now? ") print. Print ("Please wait for a while...") salary + = recharge print ("You have recharged!") Ve bought: ", shoppingmart) print (" Your balance is: ", salary) print (" Welcome your next) Oods: 1 Your balance is not enough! Please try sth else. Do you. Ook RMB 80 - -- Please choose goods: 1 You have bought Huawei! Your balance is: 27200 Do Rphone, Your balance is: RMB 26900 Do you want to quit now? Q ----------items---------- 1. XT coming! 

is the whole content of this article. I hope it will be helpful to everyone's learning, and I hope you will support the script home.

, you may be interested in the article:


This concludes the body part

This paper fixed link:http://www.script-home.com/python-implementation-of-shopping-cart-program.html | Script Home | +Copy Link

Article reprint please specify:Python implementation of shopping cart program | Script Home

You may also be interested in these articles!