Skip to content

Commit a30f057

Browse files
authored
Add files via upload
1 parent fc3640c commit a30f057

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Finding the percentage.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 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.
2+
3+
# Input Format
4+
5+
# The first line contains the integer , the number of students. The next lines contains the name and marks obtained by that student separated by a space. The final line contains the name of a particular student previously listed.
6+
7+
# Constraints
8+
9+
# Output Format
10+
11+
# Print one line: The average of the marks obtained by the particular student correct to 2 decimal places.
12+
13+
# Sample Input 0
14+
15+
# 3
16+
# Krishna 67 68 69
17+
# Arjun 70 98 63
18+
# Malika 52 56 60
19+
# Malika
20+
# Sample Output 0
21+
22+
# 56.00
23+
# Explanation 0
24+
25+
# Marks for Malika are whose average is
26+
27+
# Sample Input 1
28+
29+
# 2
30+
# Harsh 25 26.5 28
31+
# Anurag 26 28 30
32+
# Harsh
33+
# Sample Output 1
34+
35+
# 26.50
36+
37+
38+
39+
40+
41+
42+
if __name__ == '__main__':
43+
n = int(input())
44+
student_marks = {}
45+
46+
for _ in range(n):
47+
name, *line = input().split()
48+
scores = list(map(float, line))
49+
student_marks[name] = scores
50+
51+
query_name = input()
52+
53+
marks = sum(student_marks[query_name])/3
54+
print("{:.2f}".format(marks))
55+

0 commit comments

Comments
 (0)