you have a record of students. each record contains the student's name and their percent marks in maths physics and chemistry. the marks can be floating values. the user enters some integer followed by the names and marks for students. you are required to save the record in a dictionary data type. the user then enters a student's name. output the average percentage marks obtained by that student correct to two decimal places.
Answers
Answered by
2
The following code can be followed to get the two digit percentage in Java.
However, the format will be same in other language as well.
# Enter your code here. Read input from STDIN. Print output to STDOUT
N = int(raw_input())
results = {}
for i in range(N):
a = raw_input().split(' ')
results[a[0]] = [float(x) for x in a[1:]]
student = raw_input()
print ""%.2f"" %(sum(results[student])/len(results[student]))
Similar questions