python模拟购物模块_python -模拟购物 -赊账版 粗糙之极

 2023-09-07 阅读 18 评论 0

摘要:#!/usr/bin/envpython#byramans_list=[‘car‘,‘bike‘,‘book‘,‘milk‘]p_list=[‘300000‘,‘2000‘,‘98‘,‘6‘]g_list={}forpins_list:g_list[p]=p_list[s_list.index(p)]print‘‘‘---------------------------------------+Howmuchmoneyuhave

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

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/17904.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息