#!/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的原创作品,谢绝转载,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python---内置函数
python内置函数
python 内置函数
















