博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mini program
阅读量:7098 次
发布时间:2019-06-28

本文共 2174 字,大约阅读时间需要 7 分钟。

1.Shopping cart

1 # bug分开添加同一种商品到购物车的时候  会以两种商品打印 2 # 未对用户输入的字符串进行判断 3 goods_name = [ 4     {
"Name": "MI 8", "Price": 3699}, 5 {
"Name": "MI 6", "Price": 2699}, 6 {
"Name": "MI mini", "Price": 169}, 7 {
"Name": "MI watch", "Price": 179}, 8 ] 9 print("Welcome to Rainm's shopping center!!\nWhat do you want to do:")10 choice = input("1. Enter the shop\n2. I am just looking")11 shopping_car = []12 flag = True13 total = 014 if choice == '2':15 print("See you next time")16 else:17 print("Nice to meet you, here are good: ")18 while flag:19 for i, k in enumerate(goods_name): #枚举??20 print("No.{} {} {}".format(i + 1, k["Name"], k["Price"]))21 goods_choice = int(input("Which goods you want to add it to your shopping car(Press -1 to exit): "))22 if goods_choice == -1:23 print("What do you want to do:")24 next_choice = input("1. check shopping car\n2. I want to see the next store")25 if next_choice == '1':26 print("Here are your shopping car: ")27 for k in shopping_car:28 print("Name: {} Price: {} Count:{}".format(k["Name"], k["Price"], k["Count"]))29 total += int(k["Price"] * goods_num)30 print("Total:{}$".format(total))31 else:32 print("See you next time.")33 break34 flag = False35 print("What do you want to do: ")36 next_choice1 = input("1. Balance my shopping car.\n2. Continue to shopping.\n3. Exit the store.")37 if next_choice1 == '1':38 shopping_car.clear()39 print("Balance successfully!!It totally costs {}$\nHaving a nice day!".format(total))40 elif next_choice1 == '2':41 flag = True42 43 else:44 goods_num = int(input("And how much do you want to buy: "))45 shopping_car.append({
"Name": goods_name[goods_choice - 1]["Name"], "Price": goods_name[goods_choice - 1]["Price"], "Count": goods_num})

 

转载于:https://www.cnblogs.com/Rainm/p/9618096.html

你可能感兴趣的文章
jquery获取css颜色值返回RGB应用
查看>>
(void __user *)arg 中__user的作用
查看>>
Redefine:Change in the Changing World
查看>>
POJ 3436 ACM Computer Factory 最大流
查看>>
atitit。全局变量的设计与实现 java php的异同
查看>>
自己定义控件-画板,橡皮擦,刮刮乐
查看>>
spark 按照key 分组 然后统计每个key对应的最大、最小、平均值思路——使用groupby,或者reduceby...
查看>>
顺序表示的线性表——顺序表
查看>>
categorys源码
查看>>
XML学习总结(二)——XML入门
查看>>
主键思维定势导致的惨案
查看>>
Oracle中merge into的使用
查看>>
C与asm链接和内嵌
查看>>
349元我们应该有什么样的期待-原道N12豪华版 RK2906入手初体验
查看>>
简单PHP留言板之三 —— 头部文件以 及单 独设置PHP文件编码
查看>>
Android中Context
查看>>
WordPress超级基本教程(转)
查看>>
Python基础 3----文件和网络
查看>>
模块的耦合和内聚
查看>>
对话框
查看>>