当前位置: 首页 > news >正文

网络销售怎么做网站/2023年重大时政热点

网络销售怎么做网站,2023年重大时政热点,南阳哪有做网站公司,智能小程序收款码这篇文章主要为大家详细介绍了Python实现购物车程序,具有一定的参考价值,感兴趣的小伙伴们可以参考一下本文实例为大家分享了程序:Python购物车程序,具体内容如下需求:启动程序后,让用户输入工资&#xff0…

这篇文章主要为大家详细介绍了Python实现购物车程序,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了程序:Python购物车程序,具体内容如下

需求:启动程序后,让用户输入工资,然后打印商品列表

允许用户根据商品编号购买商品

用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒

可随时退出,退出时,打印已购买商品和余额

如余额不足,可充值

代码:

#coding=utf-8

#Version:python 3.6.0

#Tools:Pycharm 2017.3.2

_date_ = '2018/4/16/016 14:50'

_author_ = 'Hongyong'

salary = int(input("Please input your salary: "))

shoppingmart = []

items = (["1","Huawei","¥",2800],

["2","Earphone","¥",300],

["3","Book","¥",80])

msg_items = '''

----------items----------

1. Huawei ¥ 2800

2. Earphone ¥ 300

3. Book ¥ 80

-------------------------

'''

print(msg_items)

while True:

shopindex = int(input("Please choose goods: "))

if salary > items[shopindex-1][3]:

shoppingmart.append(items[shopindex-1])

salary -= int(items[shopindex-1][3])

print("You have bought {name} !".format(name = items[shopindex-1][1]))

print("Your balance is: ¥",salary)

decision = input("Do you want to quit now?")

print(msg_items)

else:

print("Your balance is not enough! Please try sth else.")

recharge_ans = input("Do you want to recharge?")

if recharge_ans == "y":

recharge = int(input("Please input money: "))

print("Please wait for a while...")

salary += recharge

print("You have recharged successfully!")

print("And the balance is: ",salary,"now!")

decision = input("Do you want to quit now?")

print(msg_items)

if decision == "q":

break

else:

continue

print("You have bought: ",shoppingmart)

print("Your balance is: ¥",salary)

print("Welcome your next coming!")

程序效果:

Please input your salary: 0

----------items----------

1. Huawei ¥ 2800

2. Earphone ¥ 300

3. Book ¥ 80

-------------------------

Please choose goods: 1

Your balance is not enough! Please try sth else.

Do you want to recharge?y

Please input money: 30000

Please wait for a while...

You have recharged successfully!

And the balance is: 30000 now!

Do you want to quit now?

----------items----------

1. Huawei ¥ 2800

2. Earphone ¥ 300

3. Book ¥ 80

-------------------------

Please choose goods: 1

You have bought Huawei !

Your balance is: ¥ 27200

Do you want to quit now?

----------items----------

1. Huawei ¥ 2800

2. Earphone ¥ 300

3. Book ¥ 80

-------------------------

Please choose goods: 2

You have bought Earphone !

Your balance is: ¥ 26900

Do you want to quit now?q

----------items----------

1. Huawei ¥ 2800

2. Earphone ¥ 300

3. Book ¥ 80

-------------------------

You have bought: [['1', 'Huawei', '¥', 2800], ['2', 'Earphone', '¥', 300]]

Your balance is: ¥ 26900

Welcome your next coming!

相关推荐:

http://www.lbrq.cn/news/806041.html

相关文章:

  • 男女做羞羞事的网站/站长工具如何使用
  • 成都网站制作怎么样/阿里云搜索引擎
  • flask做视频网站/如何做网销
  • 网站建设备案书模板/今日预测足球比分预测
  • 企业门户网站建设渠道/种子库
  • wordpress登录页美化/青岛seo网站管理
  • 小说网站怎么做用户画像/网页百度
  • 北京P2P公司网站建设/淘宝指数查询工具
  • 开发网站有什么用/seo外链购买
  • 阿里云服务器做电影网站/佛山网站开发公司
  • 昆明cms模板建站/百度手机助手app安卓版官方下载
  • 信息科技有限公司网站建设/商品热搜词排行榜
  • 建设英文品牌网站/域名注册需要什么条件
  • 如何删除wordpress文件夹/宁波seo网页怎么优化
  • 番禺互联网公司/网站免费优化
  • 模板做网站上传/百度站长快速收录
  • 外贸网站建设升上去/广告代发平台
  • 常州做网站哪里好/郑州seo外包顾问
  • 做物流的网站有哪些/重庆seo培训
  • 深圳设计研究院总院/无锡seo
  • 装潢公司企业网站源码/seo关键词排名怎么提升
  • 高清免费素材网站/磁力链bt磁力天堂
  • 成都制作网站工作室/自媒体发布软件app
  • 具体的网站建设方案/百度快照优化排名推广怎么做
  • 外贸电商网站建设/qq群推广方法
  • 扫描二维码进入公司网站怎样做/阿里云com域名注册
  • 潍坊网站建设外包/旺道seo推广
  • 类似一起做网店的网站/舆情系统
  • 成都响应式网站建/品牌推广的渠道有哪些
  • 产品做网站推广/seo查询排名软件
  • 【深度学习①】 | Numpy数组篇
  • 软件工程:软件复用
  • Redis实战(4)-- BitMap结构与使用
  • 学习Markdown
  • Java注解与反射:从自定义注解到框架设计原理
  • ‌CASE WHEN THEN ELSE END‌