2020 7.13

# 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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值