#!/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的更多相关文章

  1. Python学习笔记(5)practice:shopping_cart

    2019-02-27 原代码: money = int(input("请输入金额:")) list = ["phone", "clothes" ...

  2. python之信用卡ATM(第五天)

    本节作业 作业需求: 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 每月22号出账单,每月10号为还款日, ...

  3. python3 购物程序

    要求: 一.启动程序后,选择是商家还是用户 1.选择商家用户 输入用户名,密码进入 选择增加商品及价格:格式:  商品名称 价格 选择编辑商品及价格:根据提示进行操作 2.选择用户 输入用户名,密码进 ...

  4. 基于python网络编程实现支持购物、转账、存取钱、定时计算利息的信用卡系统

    一.要求 二.思路 1.购物类buy 接收 信用卡类 的信用卡可用可用余额, 返回消费金额 2.信用卡(ATM)类 接收上次操作后,信用卡可用余额,总欠款,剩余欠款,存款 其中: 1.每种交易类型不单 ...

  5. Python之路 day2 购物车小程序1

    #Author:ersa ''' 程序:购物车程序 需求: 启动程序后,让用户输入工资,然后打印商品列表 允许用户根据商品编号购买商品 用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒 可随时 ...

  6. coffeescript 1.8.0 documents

    CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...

  7. git workflow常用命令

    git init git status git add readme.txt git add --all         Adds all new or modified files git comm ...

  8. 以优美方式编写JavaScript代码

    英文原文:CoffeeScript: The beautiful way to write JavaScript 我用 JavaScript 编程很多年了,写了大量的 JavaScript 代码,即便 ...

  9. python基础:三层循环

    三层循环基本演示: break_flag = False #标记1 break_flag2 = False #标记2 break_flag3 = False #标记3 while not break_ ...

随机推荐

  1. Static语句块和初始语句块的使用---2015年10月恒生电子笔试试卷

    package lhm.test; /** * @author lenovo * */public class Person { private int id; private static int ...

  2. Omi v1.0.2发布 - 正式支持传递javascript表达式

    原文地址:https://github.com/AlloyTeam/omi/ 写在前面 Omi框架可以通过在组件上声明 data-* 把属性传递给子节点. Omi从设计之初,就是往标准的DOM标签的标 ...

  3. 【树莓派】Linux 测网速及树莓派源

    这篇文章比较杂,其中包含三点:linux环境中测试网络速度,树莓派下载软件的源,部分我写好的脚本: 一.Linux 测网速 Linux 测网速: sar -n DEV 1 100 1代表一秒统计并显示 ...

  4. ArcGIS API for JavaScript FeatureLayer服务属性编辑

    首先说一下感想吧,刚入行时感觉深似海,掉到了GIS开发的陨石大坑里了,首先是学了小半年的Flex,用到了ArcGIS API for Flex,接着又是半年的ArcEngine开发,现在终于摸到了一点 ...

  5. windows phone 8.1 FlipView 实现照片自动浏览

    FlipView 控件也是一个集合控件,不过它和ListView等控件不同,ListView控件是一次显示多个项,而FlipView则是每次只显示一个项.在windows phone上通过默认的左右滑 ...

  6. 设置EditText控件中提示消息hint的字体颜色和大小

    设置EditText控件中提示消息hint的字体颜色和大小 1.设置字体大小 代码例: public void init(){ hint= (EditText) findViewById(R.id.i ...

  7. 配置uwsgi

    首先要明确的是,如果你喜欢用命令行的方式(如shell)敲命令,那可以省去任何配置. 但是,绝大多数人,还是不愿意记那么长的命令,反复敲的.所以uwsgi里,就给大家提供了多种配置,省去你启动时候,需 ...

  8. 通用数据库帮助类DBHelper(含log日志信息实时记录)

    项目需要,需要一个通用的数据库操作类,增删改查.事务.存储过程.日志记录都要有,于是在已有的帮助类上做了一些改进,并将log4j的.NET版--log4net嵌入其中记录sql的执行环境和状态. 用起 ...

  9. 老李分享:持续集成学好jenkins之安装

    老李分享:持续集成学好jenkins之安装   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq: ...

  10. MVC 5 + EF6 完整教程15 -- 使用DI进行解耦

    如果大家研究一些开源项目,会发现无处不在的DI(Dependency Injection依赖注入). 本篇文章将会详细讲述如何在MVC中使用Ninject实现DI 文章提纲 场景描述 & 问题 ...