我需要使用课堂创建一个程序来计算学生的字母成绩。对于每个学生,将从文件中读取以下数据:
加权成绩分布为:
必须打印每个学生的信息:姓名,分数,字母等级,学生总数和平均成绩。
我正在使用pythong 3.7.3
class Student(self):
dict = {}
def __init__(self):
readFile = open('student.txt','r')
for line in readFile:
id = line [:5]
id = id.strip(' ')
name = line [5:31]
name = name.strip(' ')
t1 = line[31:34]
t1 = int(t1)
t1 = t1.strip(',')
t2 = line[34:37]
t2 = int(t2)
t2 = t2.strip(',')
t3 = line[37:40]
t3 = int(t3)
t3 = t3.strip(',')
Student.dict[iden] = id, name, t1, t2, t3
readFile.close
def setID(self):
self.id
def setName(self):
self.name
def setT1(self):
self.t1
def setT2(self):
self.t2
def setT3(self):
self.t3
def getItems(self):
return Student.dict
def getID(self):
return Student.id
def getName(self):
return Student.name
def getT1(self):
return Student.t1
def getT2(self):
return Student.t2
def getT3(self):
return Student.t3
def main():
if (
我希望结果输出看起来像这样:
name scores letter grade
Jason Wells 100,92,80 B
Melanie Parnell 90,64,70 C
Kassie Phan 89,93,97 A
Total number of A's,B',C's
Total number of students
Average grade