A: Today is a learning list after the practice of training
Shopping Small Program:
#codeing: utf-8#__author__:D uke#date:2018/3/1/001product_list= [ ('mac',7000), ('Bike', +), ('Phone', -), ('Kindle', -), ('iwatch', the),];shopping_car=[];saving= Input ("Please input your money:") #saving Deposit for the consumerifsaving.isdigit (): Saving=int(saving); whileTrue: #打印商品列表 forI, VinchEnumerate (Product_list,1): Print (i, v[0], v[1]); #选择购买商品的编号 Choice= Input ('Please enter the number of the purchase item [exit: Q]:') #验证用户的输入ifchoice.isdigit (): Choice=int(choice)ifChoice>0and Choice <=Len (product_list): P_item= product_list[choice-1]; #挑出选择的商品ifp_item[1] <Saving: #判断余额是否够买此商品 saving-= p_item[1]; #付账 shopping_car.append (P_item); #将商品加入订单 Print ("you purchased%s successfully"% p_item[0]); Else: Print ("your balance is low and the%s is left"%saving) #余额不足的提示Else: Print ('your product number does not exist ...'); #选择的商品不存在时 elif Choice=='Q': Print ("----------The items you purchased are as follows-------"); #退出下单操作 forI,vinchEnumerate (Shopping_car,1): #显示已购商品 print (i,v) print ("your balance is:%s"%saving) #显示余额 Break; Else: Print ('Invalid input ...'); #错误输入提示
There is no clear place to welcome the message.
Python Learning day04