标签:每天一段python
#!/usr/bin/env python //程序开始 #Date: 2016-01-12 import sys wide = 51 title = ‘shop list‘ none = (wide - len(title) - 2) // 2 Goods = [‘Iphone‘,‘Quecao‘,‘LV‘,‘Trival‘,‘watch‘] Prices = [5000,99,999,19999,3000] print ‘*‘ * wide print ‘*‘ * none + ‘ ‘ + title + ‘ ‘ + ‘*‘ * none print Goods print Prices print ‘*‘ * wide //打印列表单 Money = int(raw_input("Welcome, please input your wages: ")) if Money == 0: print "Your wages is %d, can‘t pay for anything!" %Money elif Money > min(Prices): //min(Prices)取得Prices中的最小值 shop = raw_input("Please input what you want on the list:") if shop in Goods: print "Congratulations, you have got %s!" %shop pay_price = Prices[Goods.index(shop)] //根据选择内容查询价格 money_left = Money - pay_price //余额 print "Your wage left: %s" %money_left else: print "Sorry, your choose not in list! You can try again!" else: print "You have enough money, syetem will exit!" sys.exit() //程序结束
本文出自 “经验来自痛苦” 博客,谢绝转载!
标签:每天一段python
原文地址:http://strike.blog.51cto.com/10311680/1734393