python-练习4
来源:互联网 发布:阿里云国际版怎么注册 编辑:程序博客网 时间:2024/05/11 19:37
代码如下:
from operator import addnotice='''\welcome to my shopping car1 iphone 58002 book 1003 bike 2004 iphone8 8000\'''amount=raw_input('You amount in credict card')items=[5800,100,200,8000]name={'1':'iphone','2':'book','3':'bike','4':'iphone8'}sum1=[0]named=[]print noticewhile True: choice=raw_input(">>>") if choice.isdigit(): if ((reduce(add,sum1)+items[int(choice)-1])<int(amount)): sum1.append(items[int(choice)-1]) named.append(name[choice]) print 'added [', name[choice], '] to your shopping' else: print 'please try another one' if choice=='q': print'=====================================' print 'goods price' for i in range(1,len(sum1)): print named[i-1],' ',sum1[i] print 'sum:',reduce(add,sum1) print 'balance',int(amount)-reduce(add,sum1)
阅读全文
0 0
- python game练习4
- Python 练习实例4
- Python练习4
- Python实例练习4
- python-练习4
- python---练习4
- python练习4
- Python -练习4
- Python 练习实例4
- Python 练习实例4
- Python练习100例-4
- Python 4-1练习实例
- Python 练习4-2实例
- python练习
- python练习
- Python练习
- python练习
- python练习
- fragment中onCreateView与onActivityCreated的区别,以及fragment中生命周期的利用
- post请求
- Lavarel文件上传
- 【补充】ARM MMU页表框架
- LeetCode
- python-练习4
- 使用golang快速开发微信公众平台(九):下载对账单
- 10分钟学会如何使用Shiro
- 安卓实现okhttp上传视频到php服务器
- Leetcode Sort List
- Github入门教程
- 线性结构——单链表
- asp.net c# 發送mail
- html 网站发布到公网