Shoping shopping (learned the old boy video written)

Source: Internet
Author: User


#!/usr/bin/python
Import syslog
Import Sys
this_year=2015



product=[' Apple ', ' coffee ', ' pc ', ' Rebot ', ' clothes ', ' licai '] #创建数组

PRICE=[4999,30,8000,100000,1000,500] #创建数组

Qingdan = [] #创建数组

While True:
Try

Gongz=int (raw_input (' \033[33;1mplease input you gz:\033[0m '). Strip ())

Break

#输入工资, not numeric exception handling

#except ValueError:
Except ValueError:
Print "error:you must input a num"

While True:

print ' \033[35;1mplease looking for caidan\033[0m ' #输出你的菜单

For line in product:

#在你的数组中循环

Print "\033[32;1m%s\t%s\033[0m"% (Line,price[product.index (line)])

#输出你的购物清单

If Gongz < min (price): #判断是否购买的起

Print "\033[34;1m didn ' t buy this is buy\033[0m"

Print "\033[34;1m", Qingdan, "\033[0m"

#输出你已经购买的

Sys.exit ()

Else

Goumai = Raw_input (' \033[32;1m you need shopping,please take it\033[0m ')

#选择购买的物品

If goumai== ' exit ':

#exit exit Judgment

Print "\033[35;1m you buy", Qingdan, "\033[0m"

Sys.exit ()

If Goumai in product:

If Gongz < Price[product.index (Goumai)]:

#判断是否购买的了

Print "\033[31;1myou can ' t buy", Goumai, "Youhave", Gongz, "\033[0m"

#输出不能买已经清单

Continue

Else

Qingdan.append (Goumai)

#购买的物品添加到数组中

Gongz = Gongz-price[product.index (Goumai)]

#工资减去物品的价格

Print "\033[35;1m you buy", Qingdan, "We have", Gongz, "\033[0m"

Else
print "\033[31;1mdon ' t hava this wp,you has", Gongz, "\033[0m"

Continue


This article is from the "Once Operations" blog, please be sure to keep this source http://bluechen.blog.51cto.com/8739192/1695956

Shoping shopping (learned the old boy video written)

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.