• 购物车 python作业



    功能要求:

    要求用户输入总资产,例如:2000
    显示商品列表,让用户根据序号选择商品,加入购物车
    购买,如果商品总额大于总资产,提示账户余额不足,否则,购买成功。
    附加:可充值、某商品移除购物车
    goods = [
    {"name": "电脑", "price": 1999},
    {"name": "鼠标", "price": 10},
    {"name": "游艇", "price": 20},
    {"name": "美女", "price": 998},
    ]

    goods = [
    {"name": "电脑", "price": 1999},
    {"name": "鼠标", "price": 10},
    {"name": "游艇", "price": 20},
    {"name": "美女", "price": 998},
    ]
    zzc = int(input('请输入总资产:'))
    car = []
    while True:
    for i1 in enumerate(goods):
    print(i1[0],i1[1].get('name'),i1[1].get('price'))
    ret = int(input('请根据序号选择商品,退出输入88:'))
    for i2 in enumerate(goods):
    if i2[0] == ret:
    car.append(goods[ret])
    print(car)
    if ret == 88:
    for i3 in car:
    zj = 0
    zj = i3['price'] + zj
    if zj > zzc:
    print('余额不足,请充值')
    # xz = input('余额不足,选择充值输入y,退出购买输入n:')
    # if xz == 'y':
    # jj = int(input('请输入充值金额:'))
    # zzc = jj + zzc
    # else:
    # print('欢迎下次光临')
    else:
    print('购买成功')
    break


  • 相关阅读:
    (*^_^*)Pose Estimation:DensePose
    (^_^)Pose Estimation:SamplePose
    [*v*/]人脸识别任务算法RetinaFace
    [*v*/]人脸识别任务算法MTCNN
    从Winograd算法看INT8量化及卷积加速原理
    [*_*/]Darknet && Mobilnet
    从TensorRT看INT8量化原理
    SSD算法精度
    信用评分卡模型的理论准备
    分类模型评估指标
  • 原文地址:https://www.cnblogs.com/koushuige/p/7800224.html
Copyright © 2020-2023  润新知