Python from getting started to discarding-day05-formatted output shopping cart

Source: Internet
Author: User
Tags macbook

#Author: liuxing#Date: 2017-12-25#Shopping Jobsmy_money=10000my_commodity=[]commoditys=[("iphone", 4500), ("MacBook", 8000), (" Book", 90), ("Bicyle", 1200), ("PC", 3000), ("Coffee", 20)] whileTrue:Print("Current Balance =%d"%My_money)Print("Product Information")     forCommodityinchCommoditys:Print("%d.%s%d Yuan"% (Commoditys.index (commodity) +1,commodity[0],commodity[1]), end=" ")    Print() Choice=int (Input (">>>:"))    ifChoice==-1:         Break    Else:        ifCommoditys[choice-1][1]>My_money:Print("insufficient balance, please re-select! ")            Continue        Else:            ifCOMMODITYS[CHOICE-1]inchMy_commodity:index=my_commodity.index (commoditys[choice-1]) My_commodity[index+1]+=1My_money-=commoditys[choice-1][1]            Else: My_commodity.append (Commoditys[choice-1]) My_commodity.append (1) My_money-= Commoditys[choice-1][1]Print(my_commodity)
Current Balance =10000Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:1Current Balance=5500Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:1Current Balance=1000Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:3Current Balance=910Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:3Current Balance=820Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:3Current Balance=730Product Information1.iphone 4500 Yuan 2.macbook 8000 Yuan 3.book 90 Yuan 4.bicyle 1200 Yuan 5.pc 3000 Yuan 6. Coffee 20 USD>>>:-1[('iphone', 4500), 2, (' Book', 90), 3]

Python from getting started to discarding-day05-formatted output shopping cart

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.