标签:linux
#!/usr/bin/env python #coding:utf-8 __author__ = "mmm" ‘‘‘ @author:sum @file:shopping car.py @time:7/12/1710:48 PM @desc ‘‘‘ iphone = 0 book = 0 bike = 0 money = input("请输入账户金额:") list = {(‘iphone‘,8000), (‘book‘,100), (‘bike‘,200)} for i in enumerate(list): a = i[0] b = i[1][0] c = i[1][1] print a,b,c while True: num = raw_input("请输入商品序号:") if num == ‘0‘: if money > 200: money = money-200 bike = bike +1 print ‘账户余额%s‘ %money else: print ‘余额不足‘ if num == ‘1‘: if money > 100: money = money -100 book = book +1 print ‘账户余额%s‘ %money else: print ‘余额不足‘ if num == ‘2‘: if money > 8000: money = money -8000 iphone = iphone +1 print ‘账户余额%s‘%money else: print ‘余额不足‘ if num == ‘quit‘: print ‘购买清单 iphone %s \n book %s\n bike %s\n‘ %(iphone,book,bike) print ‘账户余额 %s‘ %money break
标签:linux
原文地址:http://supermk.blog.51cto.com/12763230/1947630