python -模擬購物 -賒賬版 粗糙之極

#!/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)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章