问题描述
课程信息
行格式:课程代码〜课程名称〜学期〜年级〜讲师
学生信息
行格式:卷号〜全名
关于成绩的信息
行格式:课程代码〜学期〜年〜卷号〜年级
可能的成绩是A,AB,B,BC,C,CD,D以及相应的成绩点10,9,8,7,6,5和4.学生的平均成绩是他/她的成绩点除以课程数量。例如,如果学生参加了两门A和C级课程,则平均成绩为8.50 =(10 + 7)÷2。如果学生没有完成任何课程,则平均成绩点定义为0.
您可以假设数据内部一致。对于每个等级,输入数据中都有相应的课程代码和卷号。
输入的每个部分都以包含单个关键字的行开头。第一部分以包含课程的一行开头。第二部分以包含学生的一行开头。第三部分以包含成绩的行开头。输入的结尾用包含EndOfInput的行标记。
写一个Python程序来读取上面描述的数据并打印出列出平均成绩点的行对于每个学生,格式如下:
卷号〜全名〜平均成绩点
您的输出应按卷号排序。等级点平均值应舍入为小数点后的2位数。使用内置函数round()。
这是一个示例输入及其相应的输出。
样品输入
课程
TRAN~变身〜1~2011-2012~Minerva McGonagall
CHAR 〜魅力~1~2011-2012~Filius Flitwick
学生
SLY2301~Hannah Abbott
SLY2302~Euan Abercrombie
SLY2303~Stewart Ackerley
SLY2304~Bertram Aubrey
SLY2305~Avery
SLY2306~Malcolm Baddock
SLY2307 ~Marcus Belby
SLY2308~凯蒂贝尔
SLY2309~天狼星猎户座黑色
等级
TRAN~1~2011 -2012~SLY2301~AB
TRAN~1~2011-2012~SLY2302~B
TRAN~1~2011-2012~SLY2303~B
TRAN~1~2011-2012~SLY2305~A
TRAN~1~2011-2012~SLY2306~BC
TRAN~1~2011-2012~SLY2308~ A
TRAN~1~2011-2012~SLY2309~AB
CHAR~1~2011-2012~SLY2301~A
CHAR~1 ~2011-2012~SLY2302~BC
CHAR~1~2011-20 12~SLY2303~B
CHAR~1~2011-2012~SLY2305~BC
CHAR~1~2011-2012~SLY2306~C
CHAR~1~2011-2012~SLY2307~B
CHAR~1~2011-2012~SLY2308~AB
EndOfInput
样本输入
SLY2301~Hannah Abbott~9.5
SLY2302~Euan Abercrombie~7.5
SLY2303~Stewart Ackerley~8.0
SLY2304~Bertram Aubrey~0
SLY2305~Avery~8.5
SLY2306~Malcolm Baddock~6.5
SLY2307 ~Marcus Belby~8.0
SLY2308~Katie Bell~9.5
SLY2309~Sirius Orion Black~9.0
我尝试了什么:
我的系统无法运行所以即时通讯要求你的帮助
Information about courses
Line format: Course Code~Course Name~Semester~Year~Instructor
Information about students
Line format: Roll Number~Full Name
Information about grades
Line format: Course Code~Semester~Year~Roll Number~Grade
The possible grades are A, AB, B, BC, C, CD, D with corresponding grade points 10, 9, 8, 7, 6, 5 and 4. The grade point average of a student is the sum of his/her grade points divided by the number of courses. For instance, if a student has taken two courses with grades A and C, the grade point average is 8.50 = (10+7)÷2. If a student has not completed any courses, the grade point average is defined to be 0.
You may assume that the data is internally consistent. For every grade, there is a corresponding course code and roll number in the input data.
Each section of the input starts with a line containing a single keyword. The first section begins with a line containing Courses. The second section begins with a line containing Students. The third section begins with a line containing Grades. The end of the input is marked by a line containing EndOfInput.
Write a Python program to read the data as described above and print out a line listing the grade point average for each student in the following format:
Roll Number~Full Name~Grade Point Average
Your output should be sorted by Roll Number. The grade point average should be rounded off to 2 digits after the decimal point. Use the built-in function round().
Here is a sample input and its corresponding output.
Sample Input
Courses
TRAN~Transfiguration~1~2011-2012~Minerva McGonagall
CHAR~Charms~1~2011-2012~Filius Flitwick
Students
SLY2301~Hannah Abbott
SLY2302~Euan Abercrombie
SLY2303~Stewart Ackerley
SLY2304~Bertram Aubrey
SLY2305~Avery
SLY2306~Malcolm Baddock
SLY2307~Marcus Belby
SLY2308~Katie Bell
SLY2309~Sirius Orion Black
Grades
TRAN~1~2011-2012~SLY2301~AB
TRAN~1~2011-2012~SLY2302~B
TRAN~1~2011-2012~SLY2303~B
TRAN~1~2011-2012~SLY2305~A
TRAN~1~2011-2012~SLY2306~BC
TRAN~1~2011-2012~SLY2308~A
TRAN~1~2011-2012~SLY2309~AB
CHAR~1~2011-2012~SLY2301~A
CHAR~1~2011-2012~SLY2302~BC
CHAR~1~2011-2012~SLY2303~B
CHAR~1~2011-2012~SLY2305~BC
CHAR~1~2011-2012~SLY2306~C
CHAR~1~2011-2012~SLY2307~B
CHAR~1~2011-2012~SLY2308~AB
EndOfInput
Sample Input
SLY2301~Hannah Abbott~9.5
SLY2302~Euan Abercrombie~7.5
SLY2303~Stewart Ackerley~8.0
SLY2304~Bertram Aubrey~0
SLY2305~Avery~8.5
SLY2306~Malcolm Baddock~6.5
SLY2307~Marcus Belby~8.0
SLY2308~Katie Bell~9.5
SLY2309~Sirius Orion Black~9.0
What I have tried:
my system is not working so im asking for your help
推荐答案
我的系统没有工作,所以我要求你的帮助
my system is not working so im asking for your help
嗯,我猜它比我的狗吃我的功课略胜一筹,但没有人会相信你......它运作良好,找不到我们,复制并粘贴任务,并试图让我们为你做...
Well, I guess it's slightly better than "my dog ate my homework", but nobody is still going to believe you ... it's working well enough to find us, copy and paste the task, and try to get us to do it for you...
显示你的代码以获得帮助。
Show your code to get help on it.
你是那个必须显示你的代码以获得帮助的人。
我们不做你的HomeWork。
HomeWork不会测试你乞求别人做你的工作的技能,它会让你思考并帮助你的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。
你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。
你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。
所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。
You are the one that have to show your code to get help on it.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
(lis1, lis2, lis3)= ([], [], [])
a = input()
while True:
if a == 'Courses':
a =input()
while a != 'Students':
lis1.append(a.split('~'))
a = input()
elif a == 'Students':
a =input()
while a!= 'Grades':
a.split(' ')
lis2.append(a.split('~'))
a = input()
elif a == 'Grades':
a =input()
while a != 'EndOfInput':
lis3.append(a.split('~'))
a = input()
elif a == 'EndOfInput':
break
else:
break
我是另一个面临同样问题解决的用户我已经成功制作了单独的课程列表(lis1),学生(lis2) ),等级(lis3)b我不知道下一步该做什么以及如何进一步接近plz帮助!!
I am another user facing the same problem to solve i have been successful in making separate list of Course(lis1), Students(lis2), Grades(lis3) but i Don't know what to do next and how to approach further plz help!!
这篇关于请解决这个Python程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!