您的位置:首页 > 编程语言 > Python开发

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()      //程序结束


本文出自 “经验来自痛苦” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: