python-Shopping Cart

Source: Internet
Author: User

1  #!/usr/bin/python2 #Coding=utf-83 ImportMultiprocessing4 5Str="Welcome to the rookie shopping system! "6 PrintStr.center (80)7Money=input ("Please enter your budget:",)8 defShow ():9     Print " "This shop offers the following products:Ten Kindle One mac A Apple $450 - mp3 - ThinkPad $800" " the Show () -d={'Kindle': 300,'mac': 500,'mp3': 30,'ThinkPad': 800,'Apple': 450} -  - defShop (Money): +d1={} -      forIinchD: +         ifMoney>D[i]: Ad1[i]=D[i] at     PrintD1 -     Print "the items you can purchase are:" -      forIinchD1: -         Print " "*12, -         Print "%-9s$%d"%(I,d1[i]) -K=raw_input ("Please enter the item you want to buy >>>",) inL=k.split (' ') -     PrintL to      forIinchL: +         ifI not  inchD: -             Print "Input error!" theK=raw_input ("Please re-enter:",) *L=[] $L=k.split (' ')Panax Notoginseng         Else: -             ifmoney<D[i]: the                 Print "Insufficient balance! " +                  Break Amoney-=D[i] the     Print "the items you purchased are:" +      forIinchRange (len (l)): -         Print "%20s"%(L[i]) $  $     Print "your balance still has%d, do you want to continue [y/n]? "% Money -k=raw_input () -     ifk=="y" ork=="Y": the Shop (Money) -     elifk=="N" ork=="N":Wuyi         Print "Thank you for coming and wishing you a happy life! " the Exit -     Else:Print "input error, enter Y or n, case insensitive! " WuShop (Money)

python-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.