-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGPA.py
More file actions
48 lines (39 loc) · 1.11 KB
/
GPA.py
File metadata and controls
48 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
There is a record of 'n' students, each record having name of student,
percent marks obtained in Maths, Physics and Chemistry. Marks can be
floating values. The user enters an integer 'n' followed by names and
marks for the 'n' students. You are required to save the record in a
dictionary data type. The user then enters name of a student and you
are required to print the average percentage marks obtained by that
student, correct to two decimal places.
Input Format:
Integer N followed by name and marks for N students.
Output Format:
Average percentage of marks obtained
Constraints
2 <= N <= 10
0 <= Marks <= 100
Sample Input:
3
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
Malika
Sample Output
56.00
"""
n = raw_input()
grades = []
for entry in range(int(n)):
grades.append([i for i in raw_input().split()])
query = raw_input()
# Find list where first item matches name in query and
# assign grades to queryResult
queryResult = [x[1:] for x in grades if x[0] == query]
total = 0
scores = 0
for x in queryResult:
for y in x:
total += float(y)
scores += 1
print "%.2f" % (float(total/scores))