小练习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('{}\t\t{}'.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

 

posted @ 2019-03-14 22:35  暴走的路人  阅读(85)  评论(0编辑  收藏  举报