zoukankan      html  css  js  c++  java
  • Python学习第二周-简易购物车练习

     1 list = ((1,'iPhone X',8300),(2,'iPad Pro',4600),(3,'IBM z10',50000),(4,'Coffee',30))
     2 print('Welecome to 7-11 !
    ')
     3 print('There are:')
     4 for i in list:print(i)
     5 balance = int(input('
    Please input your balance: 
    '))
     6 car = []  #car[name][prix]
     7 i = 0
     8 while True:
     9     code = input('Please input the code or input exit for exit:')
    10     if code == 'exit':break
    11     elif balance >= list[int(code)-1][2]:
    12         code = int(code)
    13         balance -= list[code-1][2]
    14         car.insert(i,[i+1,list[code-1][1],list[code-1][2]])
    15         i += 1
    16     elif balance < list[int(code)-1][2]:
    17         print('SO... !
    ')
    18     else:print('BIUBIUBIU')
    19 for i in car:print(i)
    20 print(balance)
  • 相关阅读:
    继承
    对象与类
    反射
    I/O流
    字符串
    Map的entrySet()方法
    接口与内部类
    Git Usage Summary
    HTML(5)
    毕业设计:下载
  • 原文地址:https://www.cnblogs.com/shuiyy/p/8137313.html
Copyright © 2011-2022 走看看