shopping_cart
#!/usr/bin/env python
# -*- coding: utf-8 -*-
print('欢迎土豪光临随心所欲旗舰店')
user_money = int(input('老板,请输入你拥有的总资产:'))
shopping_list = []
shopping_car = {}
chose_list = []
out = '谢谢惠顾小店'
goods = [
{"name": "电脑", "price": 1999},
{"name": "鼠标", "price": 10},
{"name": "游艇", "price": 20},
{"name": "美女", "price": 998},
]
# 向用户展示商品
for i in enumerate(goods):
shop_id = i[0]
shop_name = i[1].get('name')
shop_money = i[1].get('price')
print('商品id:', shop_id, '商品:', shop_name, '售价:', shop_money)
enterone = input('请问你需要选购么?y/n')
if enterone.lower() and enterone == 'y':
print('请您输入你想要的商品id,选购完毕离开请输入Q/q')
while True:
choose = input('上帝的选择:')
#if int(choose) > 3:
# print('亲爱的上帝,您输入的数字不在商品列表中,请重新输入')
# continue
#else:
# pass
if choose.lower() and choose == 'q':
break
elif int(choose) > int(len(goods)):
print('亲爱的上帝,您输入的数字不在商品列表中,请重新输入')
continue
else:
now_money = user_money
user_money = user_money - goods[int(choose)].get('price')
if now_money <= goods[int(choose)].get('price'):
print('您的账号余额:',now_money,'购买:',goods[int(choose)],'还差:',user_money)
#print('加入购物车失败!')
print("""
1 充值
2 删减购物车
""")
now_chose = input('请选择:1/2')
if int(now_chose) == 1:
recharge_money = int(input('请输入充值金额:'))
user_money = user_money + recharge_money
print('您的账号金额:',user_money)
elif int(now_chose) == 2:
for w in enumerate(chose_list):
print(w)
while True:
remove_list = input('请输入您想要删除的商品id:退出请输入Q/q')
now_list = int(len(chose_list))
if remove_list.lower() and remove_list == 'q':
print('已成功返回上一层:')
break
elif int(remove_list) < now_list:
g = None
e = chose_list[int(remove_list)]
for g in enumerate(goods):
if str(e) in g[1].get('name') :
user_money = now_money + g[1].get('price')
print('您现在的余额为:',user_money)
del chose_list[int(remove_list)]
print(chose_list)
else:
print('输入有误请重新输入') else:
chose_list.append(goods[int(choose)].get('name'))
print(chose_list)
print(chose_list)
else:
print('请稍候....,现在系统为你自动结算,')
#pass
print('您的账号余额:', user_money)
print('您购买的商品:',chose_list)
shopping_cart的更多相关文章
- Python学习笔记(5)practice:shopping_cart
2019-02-27 原代码: money = int(input("请输入金额:")) list = ["phone", "clothes" ...
- python之信用卡ATM(第五天)
本节作业 作业需求: 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 每月22号出账单,每月10号为还款日, ...
- python3 购物程序
要求: 一.启动程序后,选择是商家还是用户 1.选择商家用户 输入用户名,密码进入 选择增加商品及价格:格式: 商品名称 价格 选择编辑商品及价格:根据提示进行操作 2.选择用户 输入用户名,密码进 ...
- 基于python网络编程实现支持购物、转账、存取钱、定时计算利息的信用卡系统
一.要求 二.思路 1.购物类buy 接收 信用卡类 的信用卡可用可用余额, 返回消费金额 2.信用卡(ATM)类 接收上次操作后,信用卡可用余额,总欠款,剩余欠款,存款 其中: 1.每种交易类型不单 ...
- Python之路 day2 购物车小程序1
#Author:ersa ''' 程序:购物车程序 需求: 启动程序后,让用户输入工资,然后打印商品列表 允许用户根据商品编号购买商品 用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒 可随时 ...
- coffeescript 1.8.0 documents
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...
- git workflow常用命令
git init git status git add readme.txt git add --all Adds all new or modified files git comm ...
- 以优美方式编写JavaScript代码
英文原文:CoffeeScript: The beautiful way to write JavaScript 我用 JavaScript 编程很多年了,写了大量的 JavaScript 代码,即便 ...
- python基础:三层循环
三层循环基本演示: break_flag = False #标记1 break_flag2 = False #标记2 break_flag3 = False #标记3 while not break_ ...
随机推荐
- self-question
需要即刻提升的几大能力: 1.重装系统和安装各种软件 2.自学能力,多从实际案例中总结,多归纳反思 3.拓展人际关系,和别人沟通交流 4.遇到困难迎刃而上,而不是回避退缩
- 使用jQuery监听扫码枪输入并禁止手动输入的实现方法
@(知识点总结)[jquery|扫码抢] 基于jQuery的扫码枪监听.如果只是想实现监听获取条码扫码信息,可以直接拿来使用,如果有更多的条码判断处理逻辑需要自己扩展. 一.功能需求 使用扫码枪扫描条 ...
- layer插件
最近在做公司的官网,其中有用到layer这款插件,以前没有接触过,不过学下来觉得好用好学.下面分享一下我的学习心得. layer是web弹出层组件.在官网下载好layer后,把他部署到你的项目文件中( ...
- 搭建高可用mongo集群3.4版本
搭建高可用mongo集群3.4版本 说在开始之前:在搭建这个环境之前,已经有了一个师兄搭好的环境,虽然一样很棒,但是没有经过自己的手出来的东西,还是不属于自己,所以摸索着自己搭建一个吧,好巧不巧的是, ...
- Unity 3D Framework Designing(1)—— MVVM 模式的设计和实施(Part 2)
MVVM回顾 经过上一篇文章的介绍,相信你对 MVVM的设计思想有所了解.MVVM的核心思想就是解耦,View与ViewModel应该感受不到彼此的存在.View只关心怎样渲染,而ViewModel只 ...
- iOS开发之pch文件
项目的Supporting files文件夹下面有个“工程名-Prefix.pch”文件,也是一个头文件 pch头文件的内容能被项目中的其他所有源文件共享和访问 一般在pch文件中定义一些全局的宏 在 ...
- java开发中的链式思维 —— 设计一个链式过滤器
概述 最近在弄阿里云的sls日志服务,该服务提供了一个搜索接口,可根据各种运算.逻辑等表达式搜出想要的内容.具体语法可见https://help.aliyun.com/document_detail/ ...
- CDIF:基于JSON的SOA软件框架
通用设备互联框架(CDIF)是一个具备中美知识产权保护的,基于web的连接框架,目前有部分开源实现存放在: GitHub - out4b/cdif: Common device interconnec ...
- POPTEST老李谈Debug和Release的区别(c#) 1
POPTEST老李谈Debug和Release的区别(c#) poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
- Linux开机启动(bootstrap)上
Linux开机启动(bootstrap) 作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 计算机开机是一个神秘的过程.我们只是 ...