# 1、
list1 = ['alex', 49, [1900, 3, 18]]
name, age, birthday = list1
print(name, age, birthday)
# 2、
list2 = list(range(6))
for i in "abcde":
list2.insert(0, i)
print(list2.pop(-1))
print(list2)
# 3、
msg_dic = {'apple': 10, 'tesla': 100000, 'mac': 3000, 'lenovo': 30000, 'chicken': 10}
tag = True
while tag:
for k, v in msg_dic.items():
print("名称:" + k, "价格:" + str(v))
goods_name = input("""
请输入你想要购买的商品:
""").strip()
goods_number = input("""
请输入你要购买的数量:
""").strip()
shop_good = (goods_name, int(goods_number),int(msg_dic[goods_name]))
print(shop_good)
if goods_name in msg_dic.keys():
print("您将购买{}台{},总价为{}".format(int(goods_number), goods_name, msg_dic[goods_name]*int(goods_number)))
print("""
1 Yes
2 No
""")
cmd = input("")
while tag:
if cmd == "1":
print("正在支付!")
tag = False
elif cmd == "2":
print("正在退出")
tag = False
else:
print("请输入正确的操作")
else:
print("请输入正确的操作!")
# 4、
list3 = [11, 22, 33, 44, 55, 66, 77, 88, 99, 90]
number_dict = {}
list_demo1 = []
list_demo2 = []
for i in list3:
if i < 66:
list_demo1.append(i)
number_dict["k1"] = list_demo1
else:
list_demo2.append(i)
number_dict["k2"] = list_demo2
print(number_dict)
# 5、
s = 'hello alex alex say hello sb sb'
dict2 = {}
for i in s:
if i == " ":
pass
else:
dict2[i] = s.count(i)
print(dict2)
2020 7.13
最新推荐文章于 2024-05-03 11:07:56 发布