要求:

   1、启动程序后,让用户输入预算,然后打印商品列表
   2、允许用户根据商品编号购买商品
   3、用户选择商品后,检测余额够不够,够就直接付款,不够就提醒
   4、可随时退出,推出时打印已购买商品和余额。

umberList = [1,2,3,4,5]
ProductList = ["iphone 13","Mac book","Mi 10","jacket","trousers"]
PriceList = [4999,9999,3899,168,138]
BudGet=int(input("Please enter your budget: "))
ShoppingList = []

while True:
for i in range(5):
print(NumberList[i],ProductList[i],PriceList[i])
ComNum = int(input("Please enter the product number you need to purchase: "))
if BudGet >= PriceList[ComNum-1]:
BudGet = BudGet - PriceList[ComNum-1]
ShoppingList.append(ProductList[ComNum-1])
print("You have already purchased: ", ShoppingList)
print("Your budget balance:", BudGet)
Status = input("Exit this procedure(yes/no): ")
if Status == "yes":
print("You have already purchased: ", ShoppingList)
print("Your budget balance:", BudGet)
exit()
else:
print("Your budget is insufficient")
Status = input("Exit this procedure(yes/no): ")
if Status == "yes":
print("You have already purchased: ", ShoppingList)
print("Your budget balance:", BudGet)
exit()

最新文章

  1. mybatis批量插入返回主键问题
  2. C++内存管理的缩影
  3. [VSTS] 从零开始 Team Foundation Server 2010 安装配置详细图文教程
  4. Eclipse下快速打开本地文件的插件easy explore
  5. Linux vim的安装和配置:
  6. (转)Engineering Productivity
  7. strcasecmp在VS2010中提示未定义标识符
  8. [Android] AudioTrack实例
  9. Android全屏显示
  10. FoxOne---一个快速高效的BS框架
  11. 微信原图泄露的只能是 Exif ,你的隐私不在这!!!
  12. 《JAVA程序设计》第12周学习总结
  13. 【Luogu2458】保安站岗(动态规划)
  14. sudo解决方案企业级应用实战
  15. 用SpringCloud进行微服务架构演进
  16. [matlab] 12.Optimization Tool的使用
  17. websocket 心跳重连
  18. 2019.03.30 Head first
  19. python学习打卡 day12 生成器
  20. python实现排序算法(一)——插入排序算法

热门文章

  1. 安装nginx依赖库
  2. Jenkins自动化部署(linux环境)---代码提交触发Jenkins构建
  3. 为什么gdb通过0地址显示偏移会提示地址错误
  4. JavaScript 基础学习(三)
  5. Vue3+vite+Echarts案例大屏可视化--千峰(推荐)
  6. Solution Set - 杭电多校 2022 Day2 一句话题解
  7. 什么是bootstrap?
  8. 复制 GUI 状态
  9. wxPython绘图API
  10. Blender2.8 使用笔记