products=[ ('Iphone',5800), ('Mac Pro',9800), ('Watch',6800), ('Python',120), ('Coffee',30), ('Pen',3), ('Notebook',15), ] shopping_list=[] salary=input("请输入您的工资:") if salary.isdigit() : salary=int(salary) while True: for index,item in enumerate(products): print(index,item) option=input("请选择您要购买的商品:") if option.isdigit(): option=int(option) if 0<=option<len(products): option_product=products[option] if option_product[1]<=salary : shopping_list.append(option_product) salary-=option_product[1] print("您选择的%s已加入购物车,您的余额为" "\033[33;1m%s\033[0m" % (option_product,salary)) else: print("\033[41;1m您的当前余额为%s," "余额不足!\033[0m" % salary) else: print("抱歉,您选择的商品不存在!") elif option=='q': print("--------------shopping list------------") for p in shopping_list: print(p) print("您的余额为%s" % salary) exit() else: print("您的选择不合法!") else: print("您的工资输入不正确!")
时间: 2023-05-31 11:01:51 浏览: 87
coinbasepro:Coinbase Pro的Python API
Null is a term used in programming to define a variable or value that does not have any assigned value or is empty. It is also used to represent a lack of data or a non-existent value. In database management, null is used to indicate the absence of a value in a particular field.
阅读全文