python---购物
2016-01-12 23:00
645 查看
#!/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() //程序结束
本文出自 “经验来自痛苦” 博客,谢绝转载!
相关文章推荐
- 运维:windows+python+route的一次相遇
- python列表推导的几个例子
- python入门-基础知识
- Using Django with GAE Python 后台抓取多个网站的页面全文
- python核心编程-正则表达式之-创建字符集合
- 【学神-RHEL7】P4-Python列表操作和字符串的常用方法
- python核心编程-正则表达式之-任意单个字符
- input和raw_input区别
- python学习第二天
- 《笨办法学Python》 第11课手记
- 正则表达式 口诀 学习正则的朋友看看
- python核心编程-正则表达式之-匹配多个字符串
- Python学习手册 - 11
- python核心编程之-search函数
- python核心编程-正则表达式之match
- Python入门
- python 列表总结
- Python Division //
- python中对文件、文件夹(文件操作函数)的操作
- python selenium的模拟点击,模拟滑动等操作