• 小练习03


    #tu = ("alex", [11, 22, {"k1": "v1", "k2": ["age", "name"], "k3": (11, 22, 33)}, 44])
    #1.不可变的列表,可查,儿子不能改,孙子可能能改
    #2. 不可以
    #3.列表,可以可以修改
    #s = tu[1][2]
    #print(s)
    #s["k2"] = ["age", "name", "Seven"]
    #print(s)
    #print(tu)
    #4元祖 不可改
    
    '''
    dic = {"k1": "v1", "k2": "v2", "k3": [11, 22, 33]}
    for key in dic.keys():
        print(key)
    for value in dic.values():
        print(value)
    for k, v in dic.items():
        print(k, v)
    dic["k4"] = "v4"
    print(dic)
    dic["k1"] = "alex"
    print(dic)
    dic["k3"].append(44)
    print(dic)
    dic["k3"].insert(0, 18)
    print(dic)
    '''
    #
    '''
    li = [11, 22, 33, 44, 55, 66, 77, 88, 99, 90]
    dic = {"k1": [], "k2": []}
    for i in li:
        if i > 66:
            dic["k1"].append(i)
        if i < 66:
            dic["k2"].append(i)
    print(dic["k1"])
    print(dic["k2"])
    print(dic)
    '''
    flag = True
    while flag:
        li = ["手机", "电脑", "鼠标垫", "游艇"]
        for i in li:
            print('{}		{}'.format(li.index(i)+1, i))
        num_of_chioce = input('请输入选择的商品序号/输入Q或者q退出程序:')
        if num_of_chioce.isdigit():
            num_of_chioce = int(num_of_chioce)
            if num_of_chioce > 0 and num_of_chioce <= len(li):
                print(li[num_of_chioce-1])
            else:
                print('请输入有效数字')
        elif num_of_chioce.upper() == 'Q':break
        else:
            print('请输入数字')
    View Code
  • 相关阅读:
    数论 欧几里德算法 以及 欧几里得拓展
    数论 快速幂的原理讲解
    汉诺塔模板
    C++ 迭代器运算
    C++ STL vector set map 简易用法
    C++ 使用指向函数的指针数组
    Codeforces 718C 线段树+矩乘
    BZOJ 2506 分块
    Codeforces 455D 分块+链表
    Codeforces 19E 树上差分
  • 原文地址:https://www.cnblogs.com/bzluren/p/10534129.html
Copyright © 2020-2023  润新知