python——shopping car
# _Author:huang
# date: 2017/11/26 # 简单的购物车程序
money = input("money:") product_list = [
("Mac", 9000),
("Kindle", 300),
("Tesla", 8000),
("book", 60),
("bike", 400)
] shopping_car = [] if money.isdigit():
money = int(money) while True:
for i, v in enumerate(product_list, 1):
print(i, '>>>', v)
choice = input("请输入商品编号:[退出:q]:")
if choice.isdigit():
choice = int(choice)
if choice >= 0 and choice <= len(product_list):
p_item = product_list[choice-1]
if p_item[1] < money:
money -= p_item[1]
shopping_car.append(p_item)
print(p_item)
else:
print("余额为%s,余额不足"% money)
else:
print("编码不存在!")
elif choice == 'q':
print("-----你后买的商品如下----")
for i in shopping_car:
print(i)
print("你的余额为:%s"% money)
break
else:
print("无效输入") else:
print("Invialue number")
python——shopping car的更多相关文章
- python shopping incomplete code
#shopping code#shopping.py#导入登录模块import login# shop car beginningsalary = input("请输入工资:\t" ...
- Python开发【第二章】:Python的数据类型
基本数据类型 一.整型 如: 18.73.84 整型具备如下功能: class int(object): """ int(x=0) -> int or long i ...
- Python之路,Day2 - Python基础,列表,循环
1.列表练习name0 = 'wuchao'name1 = 'jinxin'name2 = 'xiaohu'name3 = 'sanpang'name4 = 'ligang' names = &quo ...
- Py修行路 python基础(二)变量 字符 列表
变量 容器 变量名 标记 数据的作用 字符编码 二进制位 = bit1个二进制位是计算机里的最小表示单元 1个字节是计算机里最小的存储单位 8bits = 1Byte =1字节1024Bytes = ...
- Python开发【第二章】:数据类型
基本数据类型 一.整型 如: 18.73.84 整型具备如下功能: class int(object): """ int(x=0) -> int or long i ...
- 【LeetCode】638. Shopping Offers 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 回溯法 日期 题目地址:https://le ...
- python学习笔记(列表、元组、购物车实例)
一.列表 列表和字典是最常用的两种数据类型 1. 需求:怎么存放班级80多人的姓名,如何实现? names = ["Zhangyang","Guyun",&qu ...
- Python从破门而入到夺门而出
MD版网盘备份: 链接: https://pan.baidu.com/s/1kVJNRSz 密码: agxt 基于<简明Python教程> 一.Python概览 1.使用PyCharm是非 ...
- python 模块基础介绍
从逻辑上组织代码,将一些有联系,完成特定功能相关的代码组织在一起,这些自我包含并且有组织的代码片段就是模块,将其他模块中属性附加到你的模块的操作叫做导入. 那些一个或多个.py文件组成的代码集合就称为 ...
随机推荐
- Exception thrown on Scheduler.Worker thread. Add `onError` handling
<html> <head></head> <body> java.lang.IllegalStateException: Exception throw ...
- Spring MVC框架处理Web请求的基本流程
- VTK使用矢量数据弯曲几何体
vtkWarpVector is a filter that modifies point coordinates by moving points along vector times the sc ...
- 评分模型的检验方法和标准&信用评分及实现
评分模型的检验方法和标准通常有:K-S指标.交换曲线.AR值.Gini数等.例如,K-S指标是用来衡量验证结果是否优于期望值,具体标准为:如果K-S大于40%,模型具有较好的预测功能,发展的模型具有成 ...
- 《深度探索C++对象模型》调用虚函数
如果一个类有虚函数,那么这个类的虚函数会被放在一个虚函数表里面, 使用这个类声明的对象中,会有一个指向虚函数表的指针,当使用指向 这个对象的指针或者这个对象的引用调用一个虚函数的时候,就会从虚函数表中 ...
- [ci]容器ci索引
伙计们: 有任何意见或建议或看不懂的请在对应的文章下留言(请注明上下文) 我会及时改动. 这是以前的一些在物理机上搞过 [ci]容器ci索引 http://www.cnblogs.com/iiiihe ...
- users-and-groups-in-linux
https://www.tecmint.com/compress-files-and-finding-files-in-linux/ https://www.tecmint.com/manage-us ...
- 【原创 Hadoop&Spark 动手实践 3】Hadoop2.7.3 MapReduce理论与动手实践
开始聊MapReduce,MapReduce是Hadoop的计算框架,我学Hadoop是从Hive开始入手,再到hdfs,当我学习hdfs时候,就感觉到hdfs和mapreduce关系的紧密.这个可能 ...
- python线程池(threadpool)模块使用笔记 .python 线程池使用推荐
一.安装与简介 pip install threadpool pool = ThreadPool(poolsize) requests = makeRequests(some_callable, li ...
- [转]decorator(HTML装饰器)
原文地址:https://blog.csdn.net/jzh440/article/details/7770013 1>:每当遇到一个新的技术,首先我会问自己,这个技术是做神马的?用这个技术有神 ...