Python Job shopping Mall

Source: Internet
Author: User

Homework: Shopping Malls

1, commodity display, price

2. Bank card balance

3. Pay the bill

The program flowchart is as follows:

The code is as follows:

Shopdisplay = {' clothes1 ': ' 498 ', ' Jeans ': ' $ ', ' shoes ': ' 289 ', ' hat ': ' A ', ' clothes2 ': ' 599 '}print (Shopdisplay) Shoppingcartprice = [] #购物车商品价格ShoppingCart = {} #购物车while true:thing = input ("Want to BU Y: ") Price = shopdisplay['%s '%thing] shoppingcart.update ({'%s '%thing: '%s '%price}) Shoppingcartprice.append ( '%s '% price) answer = input ("Does want to continue buy something else? Please say yes or no:\n ") if answer = = ' Yes ': Continue Else:breakdef shit (): #判断余额是否 Greater than the item to be bought sum = 0 Totalmoney = $ for i in shoppingcartprice:sum = sum + int (i) Totalmoney = Tota Lmoney-sum if Totalmoney > 0:a = input ("Does really want to buy tins?" Please enter Yes or no!\n ") if a = = ' Yes ': print (" Successful,wish you a Happy shopping!\n ") Else : Print ("Thanks come to My") exit () Else:print ("Sorry,you has not enough moneY! Please remove somethings!\n ") sum = 0TotalMoney = 1000for i in shoppingcartprice:sum = sum + int (i) Totalmoney = Tot ALMONEY-SUMIF Totalmoney > 0:a = input ("Does really want to buy tins?" Please enter Yes or no!\n ") if a = = ' Yes ': print (" Successful,wish you a Happy shopping!\n ") exit () El Se:exit () else:print ("Sorry,you has not enough money! Please remove somethings!\n ") while True:print (" Your shopping cart has this thing:\n ") print (SHOPPINGCA RT) Print ("If you don't want to del,please enter '. ')            \ n ") del_thing = input (" Please input the goods so you don't want to buy:\n ") if del_thing = = '. ': Break s = shoppingcart['%s '% del_thing] shoppingcart.pop ('%s '% del_thing) Shoppingcartprice.remo ve (s) #删除不买的东西shit ()

  

Code is very simple, the operation of the basic implementation of the function, will look at it .... Later to optimize

Python Job shopping Mall

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.