20181025

# 3.lis = [2, 3, "k", ["qwe", 20, ["k1", ["tt", 3, "1"]], 89], "ab", "adv"]
# lis = [2, 3, "k", ["qwe", 20, ["k1", ["tt", 3, "1"]], 89], "ab", "adv"]
# lis[3][2][1][0] = lis[3][2][1][0].upper()
# lis[3][2][1][0] = "TT"
# lis[3][2][1][0] = lis[3][2][1][0].replace("t", "T")
# lis[3][2][1][1] = "100"
# lis[3][2][1][1] = str(lis[3][2][1][1] + 97)
# lis[3][2][1][1] = str(lis[3][2][1][1]).replace("3", "100")
# lis[3][2][1][2] = int(lis[3][2][1][2]+"01")
# lis[3][2][1][2] = 101
# lis[3][2][1][2] = int(lis[3][2][1][2].replace("1", "101"))
# print(lis.index(["qwe", 20, ["k1", ["tt", 3, "1"]], 89]))
# 4. li = ["alex", "eric", "rain"]
# li = ["alex", "eric", "rain"]
# s = ""
# for name in li:
# s += name+"_"
# print(s.strip("_"))
# print(s[:len(s)-1]) # 当我确定最后一个一定是_的时候

# print("_".join(li))
# 5.
# li = ["alex", "WuSir", "ritian", "barry", "wenzhou"]
# for i in range(len(li)):
# print(i)
# 6.
# lst = []
# # 方案一
# for i in range(0,101,2):
# lst.append(i)
# # 方案二
# for i in range(101):
# if i % 2 == 0:
# lst.append(i)
# 7.
# lst = []
# for i in range(50):
# if i % 3 == 0:
# lst.append(i)


# 10. 利for循环和range,将1-30的数字次添加到个列表中,并循环这个
# 列表,将能被3整除的数改成*
# lst = []
# for i in range(30, 0, -1):
# lst.append(i)
#
# # 如果在循环里用到了索引。
# for i in range(len(lst)):
# if lst[i]%3 == 0:
# # 把元素换成*
# # lst[索引] = "*"
# lst[i] = "*"
# print(lst)


# 11. li = ["TaiBai ", “ale xC", “AbC ", "egon", " ri TiAn", "WuSir", " aqc"]
# li = ["TaiBai ", "ale xC", "AbC ", "egon", " ri TiAn", "WuSir", " aqc"]
# lst = []
#
# for el in li:
# el = el.replace(" ", "")
# if el.capitalize().startswith("A") and el.endswith("c"):
# lst.append(el)
# print(lst)


# 12.开发敏感词语过滤程序,提示户输评论内容,如果户输的内容中
# 包含特殊的字符:
# 敏感词列表 li = ["苍师", "东京热", "武藤兰", "波多野结"]
# 则将户输的内容中的敏感词汇替换成等度的*(苍师就替换***),并添
# 加到个列表中;如果户输的内容没有敏感词汇,则直接添加到上述的列
# 表中。

# lst = []
# li = ["苍师", "东京热", "武藤兰", "波多野结衣"]
#
# content = input("请输入你的评论:")
# for el in li:
# if el in content:
# content = content.replace(el,"*"*len(el))
# lst.append(content)
#
# print(lst)

# 13.大学计算机基础-数据结构(顺序表-->栈->树的非递归遍历)
# li = [1, 3, 4, "alex", [3, 7, 8, "TaiBai"], 5, "RiTiAn"]
# # 循环打印列表中的每个元素,遇到列表则再循环打印出它⾥⾯的元素。
#
# for el in li:
# if type(el) == list: # 百度, 谷歌, stackoverflow
# for el2 in el:
# if type(el2) == str:
# print(el2.lower())
# else:
# print(el2)
# else:
# if type(el) == str:
# print(el.lower())
# else:
# print(el)


# 14. 把班级学数学考试成绩录个列表中: 并求平均值. 要求: 录的时候
# 要带着名录, 例如: 张三_44

# lst = [] # 张三_44, 张三_44, 张三_44
# # 数据的录入
# while 1:
# content = input("请输入学生信息(q)退出:")
# if content.upper() == "Q":
# break
# lst.append(content)
#
# # 计算总分
# score = 0
# for el in lst: # 张三_44
# score += int(el.split("_")[1])
#
# # 平均值
# print(score / len(lst))

# 15.
# lst = []
# n = int(input("请输入一个数:"))
# for i in range(1, n):
# if i % 7 == 0 or "7" in str(i):
# lst.append("咣")
# else:
# lst.append(i)
# print(lst)
posted @ 2018-10-25 21:58  chenshanqin20181017  阅读(70)  评论(0编辑  收藏  举报