Use the list and while to Build Shop car
#Author: Gordon
salary = int(input("请输入你的工资:"))
goods = [('0',"Iphone",5000),('1','Laptop',3500),('2','Coffee',20),('3','Chocolate',20)]
bought =[]
while True:
want = input("请输入要买的商品编号:")
if want.isdigit():
want = int(want)
if want > 0 and want < len(goods):
if salary > goods[want][2]:
bought.append(goods[want][1])
print(goods[want][1], "商品已经加入到你的购物车!")
salary = salary - goods[want][2]
print("你的余额还有:", salary)
else:
print("您的余额已经不足")
else:
print("对不起,我们没有这件物品")
elif want == 'q':
break
else:
print("这个无效的option")
print("你已经买了",bought)
print("你的余额是:",salary)
Use the list and while to Build Shop car的更多相关文章
- 在.NET 环境中实现每日构建(Daily Build)--ccnet,MSBuild篇(转载)
每日构建,对我们团队来说一个全新的概念.随着项目开发的进展,在开发过 程需要及时反馈一些BUG和功能要求的处理情况.而在这种情况下每天或隔一段时间Build一个版本,工作量还是比较大的,所以就特别有必 ...
- (转) Quick Guide to Build a Recommendation Engine in Python
本文转自:http://www.analyticsvidhya.com/blog/2016/06/quick-guide-build-recommendation-engine-python/ Int ...
- Microsoft .NET Pet Shop 4: Migrating an ASP.NET 1.1 Application to 2.0
249 out of 297 rated this helpful - Rate this topic Gregory Leake Microsoft Corporation Alan Le, Ale ...
- [springboot 开发单体web shop] 1. 前言介绍和环境搭建
前言介绍和环境搭建 简述 springboot 本身是为了做服务化用的,我们为什么要反其道使用它来开发一份单体web应用呢? 在我们现实的开发工作中,还有大量的业务系统使用的是单体应用,特别是对于中小 ...
- 解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用
问题: Springboot启动报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ...
- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform
eclipse maven clean install 报错 1. 修改properties-->resource-->utf-8仍然报错 2.修改项目pom.xml文件,增加: < ...
- 解决 Could not find com.android.tools.build:gradle 问题
今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...
- 搭建TFS 2015 Build Agent环境(一)
Download the build agent Downloading the build agent is really simple. Navigate to your TFS control ...
- Go build constraints
Go语言有一个不(奇)错(葩)的设计,就是build constraints(构建约束).可以在源码中通过注释的方式指定编译选项,比如只允许在linux下,或者在386的平台上编译啊之类的:还可以通过 ...
随机推荐
- 用python实现按权重对N个数据进行选择
需求:某公司有N个人,根据每个人的贡献不同,按贡献值给每个人赋予一个权重.设计一种算法实现公平的抽奖. 需求分析:按照权重对数据进行选择. 代码实现: 1 def fun(n,p): 2 " ...
- Struts、Hibernate和Spring的整合
Spring整合Hibernate Spring以其开放性,能与大部分ORM框架良好的整合.这样Spring就能轻松地使用ORM. Spring提供了DAO支持,DA0组件是应用的持久层访问的重要组件 ...
- 17、OpenCV Python 数字验证码识别
__author__ = "WSX" import cv2 as cv import numpy as np from PIL import Image import pytess ...
- 有关unixODBC:Data source name not found, and no default driver specified的问题
还是昨天测试postgresql的有关Mirroring Controller的功能时出的问题(真TM是个坑). 首先说下环境: 操作系统平台:RHEL6 x86_64 unixODBC版本:2.3. ...
- ulimit -n 查看可以打开的最大文件描述符的数量
具体ulimit命令参考 https://www.cnblogs.com/wangkangluo1/archive/2012/06/06/2537677.html
- CodeCraft-19 and Codeforces Round #537 (Div. 2) C. Creative Snap 分治
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their bas ...
- 利用CountDownLatch和Semaphore测试案例
package com.cxy; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDo ...
- mysql 导入 导出
mysql导入导出sql文件 window下 1.导出整个数据库mysqldump -u 用户名 -p 数据库名 > 导出的文件名mysqldump -u dbuser -p dbname ...
- HDU - 4825 01字典树套路题
/*H E A D*/ struct Trie{ int son[maxn<<2][2]; int b[67],tot; void init(){ // memset(son,0,size ...
- http简单请求 -- 复杂请求