Python Learning day04

Source: Internet
Author: User

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

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.