elif how == 3:
with open("Class1.txt") as f:
def score(line):
return float(line.split(',')[1])
for line in f:
string_of_numbers = []
print('Total ', (len(string_of_numbers)))
print('Average ',sum(string_of_numbers)/(len(string_of_numbers)))
到目前为止,我有这个,但我想让它打印我的数据与每个名字与他们的平均分数旁边。你知道吗
这是Class1.txt的样子:
Ben, 10
John, 4
Billy, 9
Torin, 10
Charlie, 2
Celyn, 5
Ben, 5
John, 1
Billy, 5
Torin, 5
Charlie, 6
Celyn, 2
Ben, 6
John, 9
Billy, 5
Torin, 4
Charlie, 9
Celyn, 1
使用字典收集每个名称的所有值:
现在,打印结果:
印刷品:
相关问题 更多 >
编程相关推荐