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