Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 1-Sep-17 21:00pm
v2
Comments
Member 13389789 2-Sep-17 1:39am    
Show your code to get help on it.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

Quote:
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...
 
Share this answer
 
Comments
Member 13389789 2-Sep-17 1:37am    
Show your code to get help on it.
OriginalGriff 2-Sep-17 1:46am    
Precisely: we aren't here to do it for you.
Member 13389789 2-Sep-17 1:49am    
I have tried making a program for it...which din't work properly sir ...please help me to show your code
OriginalGriff 2-Sep-17 2:00am    
So you lied to us, to get us to do your homework? That's not a good start - why should we believe you now?
This is your homework: it's there to help you learn. Our doing it for you doesn't do that, and hurts you in the long term - the next task will be harder, and in the final exams you won't have access to help at all!
So sit down, read your course notes, read your course book, then read the question and start working out what to do. Try and do it in stages, checking each as you go.This isn't complex, this is basic stuff - if you can't work out how to do this, you will fail the course because it is only going to get more complex from here on in.
OriginalGriff 2-Sep-17 2:01am    
Oh, and by the way: you do realize that your tutor has access to this site as well, and would know if you copy'n'pasted a solution anyway?
Quote:
Show your code to get help on it.

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.
 
Share this answer
 
Python
(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

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!!
 
Share this answer
 
Comments
Member 13389789 2-Sep-17 7:53am    
yeah im also struck here only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900