Day2:: (python-Learning Path)-Document processing

Source: Internet
Author: User

Requirements Flowchart:

Requirements Code:

#_*_ coding:utf-8 _*_Total_money = Int (input ('Please enter your budget amount:')) Total_list= [] whileTotal_money >0:f= Open ('shopping_list','R')    Print(" "The shopping listname money" ")#Inventory Templateshopping_list= {}     forIinchF.readlines (): (k,v)=I.strip (). Split () Shopping_list[k]=vPrint(K,V)#Print a shopping listf.close () Min_money= Int (min (Shopping_list.items (), key=LambdaX:X[1]) [1]) #取商品的最小金额ifTotal_money <Min_money: #比较输入金额Print('sorry! your balance is insufficient, can not buy any goods!! bye! ~')         Break    ifTotal_money >0:choice_name= Input ('Please select the name of the product you want to buy:') Total_money= Total_money-Int (shopping_list[choice_name])ifTotal_money >0: #判断输入的商品金额是否超出余额Print('the item you purchased is:%s, the remaining amount is:%d'%(Choice_name,total_money)) Next_time= Input ('do you want to continue buying: y/n? ') total_list.append (choice_name)ifNext_time = ='y':                Continue            Else:                 Break        Else:            Print('Your amount is not enough! ')             BreakPrint('the item you purchased is:%s'%total_list)

Day2:: (python-Learning Path)-Document processing

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.