Skip to content

Commit 5c0346a

Browse files
committed
Adds find the percentage python solution
1 parent ae6bb51 commit 5c0346a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Here you will be able to find my HackerRank solutions to many challenghes, using
9595
|Python mutations|[Python](python/python_mutations.py)||
9696
|Capitalize|[Python](python/capitalize.py)||
9797
|Validating phone number|[Python](python/validating_phone_number.py)||
98+
|Find the percentage|[Python](python/find-the-percentage.py)||
9899

99100
| |[Python](python/.py)||
100101

python/find-the-percentage.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://www.hackerrank.com/challenges/finding-the-percentage/problem
2+
if __name__ == '__main__':
3+
# Get number of students
4+
n = int(input())
5+
student_marks = {}
6+
for _ in range(n):
7+
name, *line = input().split()
8+
scores = list(map(float, line))
9+
student_marks[name] = scores
10+
query_name = input()
11+
score_record = []
12+
score_record = student_marks[query_name]
13+
14+
sum_marks = 0
15+
for x in score_record:
16+
sum_marks += x
17+
percentage = "{:.2f}".format(sum_marks/len(score_record))
18+
print(percentage)

0 commit comments

Comments
 (0)