#!/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---购物
原创
©著作权归作者所有:来自51CTO博客作者StrikE_AG的原创作品,谢绝转载,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
购物车的实现(未登录时也可以使用)
平时工作的踩坑记录
redis List 拦截器 -
python---函数
定义函数,函数返回值,函数参数,全局变量和局部变量,递归函数,高阶函数,匿名函数
python 函数 基础 -
python---内置函数
python内置函数
python 内置函数