#!/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)
python -模拟购物 -赊账版 粗糙之极
原创
©著作权归作者所有:来自51CTO博客作者raman的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:弘成教育系统部MongoDB培训
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python 实现的粗糙版购物车程序
总结Pyhton编写购物车程序的技巧
Python 列表 技巧 -
Python调用模块发送邮件(粗糙版)
Python小功能(发送通知邮件)
模块 python smtplib -
python模拟ATM + 购物商城
待定
python atm