#!/usr/bin/env python
# by raman
s_list = [‘car‘,‘bike‘,‘book‘,‘milk‘]
p_list = [‘300000‘,‘2000‘,‘98‘,‘6‘]
g_list = {}
for p in s_list:
g_list[p] = p_list[s_list.index(p)]
print ‘‘‘
---------------------------------------
+ How much money u have: +
---------------------------------------‘‘‘
o_counts = raw_input(‘>‘)
print ‘‘‘
______________________________________
+ U have %s: rmb +
______________________________________ \n‘‘‘ %(o_counts)
while True:
if o_counts != 0:
ss = raw_input(‘continue to buy? yes or no: ‘)
if ss == ‘yes‘:
pass
else:
break
else:
sss = raw_input(‘quit this shopping?...‘)
if sss == ‘quit‘:
break
else:
pass
fy = ‘0‘
print ‘==================================================================================‘
print ‘#this is goods_list‘,g_list,‘#‘
print ‘==================================================================================‘
d_goods = raw_input(‘the name your will buy: ‘)
if d_goods in g_list:
h_price = float(o_counts) - float(fy)
print ‘you can buy %s‘ %(d_goods)
print ‘‘‘
Sure to buy it...
_____________
| yes | no |
-------------
‘‘‘
op = raw_input(‘> ‘)
if op == ‘yes‘:
fy = g_list[d_goods]
print ‘‘‘
____________________________
it will spent u %s‘ |
____________________________‘‘‘ %(fy)
o_counts = float(h_price) - float(fy)
if o_counts >= 0:
print "left the money %s \n " %(o_counts)
else:
print ‘u have no money to buy %s‘ %(d_goods)
print ‘‘‘
Countinue to buy?...
_____________
| yes | no |
-------------
‘‘‘
coop = raw_input(‘>‘)
if coop == ‘yes‘:
o_counts = float(h_price) - float(fy)
print "Warning!!! Credit: money:%s \n" %(o_counts)
else:
break
else:
break
elif d_goods not in g_list:
print ‘ -> %s not in below: \n %s‘ %(d_goods,g_list)
原文:http://raman.blog.51cto.com/654610/1718589
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态