标签:size code append font for 成绩 NPU int put
# 下午 # 嵌套 # l = [[]] l = [[],[]] l = [[1,2,3,4],[5,6,7,8]] print(l[0]) # [1, 2, 3, 4] l = [[1,2,3,4], [5,6,7,8]] print(l[1][2]) # 找第二行第三个元素 # 两个集合之和 l = [[1,2,3,4], [5,6,7,8]] num_sum = 0 for i in l: for j in i: num_sum += j print(num_sum) # 两个集合分别求和 l = [[1,2,3,4], [5,6,7,8]] re = 0 re1 = 0 for i in l[0]: re += i print(re) # 10 for j in l[1]: re1 += j print(re1) # 26 l = [[1,2,3,4], [5,6,7,8]] for i in l: num_sum = 0 for j in i: num_sum += j print(num_sum) # # 输入三个班级 的成绩 求和 求平均数 成绩列表 l1 = [] for j in range(3): l = list() for i in range(4): l.append(int(input(f‘请输入第{i + 1}》》》》》:‘))) print(sum(l)/len(l)) l1.append(l) print(l1)
list 嵌套 集合 求和 分求和 输入三个班级的成绩 求和 求平均数 成绩列表
标签:size code append font for 成绩 NPU int put
原文地址:https://www.cnblogs.com/lxcai213/p/13280938.html