以下是关于分数计算的一段代码 # code with open ('score.txt','r',encoding='utf-8') as f: content = [i[:-1].split(',') for i in f.readlines()] print(content) name = np.array(content).reshape(5,4) name = name[:,0] # print(name) noname = content for i in range(len(noname)): del noname[i][0] # print(noname) npcontent = np.array(noname).reshape(5,3) # print(npcontent) npcontent = np.array(npcontent,dtype=np.int64) print('np格式的数据是\n',npcontent) npscore = npcontent.cumsum(1) npscore = npscore[:,-1] # print(npscore) mean = 0 number = 0 steps = np.where(npscore>300,1,0) for i in range(len(noname)): if steps[i] == 1: mean = (npscore[i])/3 print(name[i],'的平均分是',mean) else: number = number+1 print('总分小于300分同学的人数是',number)
求解此题!!在线等,急!!