Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
The provided code stub read in a dictionary containing key/value pairs of name:[Marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal.
Example
marks key: value pairs are
‘alpha’:[20, 30, 40]
‘beta’:[30, 50, 70]
query_name = ‘beta’
The query_name is ‘beta’. beta’s average score is (30 + 50 + 70)/3 = 50.0.
The first line contains the integer n, the number of students’s records. The next n lines contain the names and marks obtained by a student, each value separated by a space. The final line contains query_name , the name of a student to query.
Print one line: The average of the marks obtained by the particular student correct to 2 decimal places.
Sample Input 0
3
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
Malika
Sample Output 0
56.00
Explanation 0
Marks of Malika are {52, 56, 60} whose average is (52 +56 +60)/3 ⇒ 56
Sample Input 1
2
Harsh 25 26.5 28
Anurag 26 28 30
Harsh
Sample Output 1
26.50
n=int(raw_input())
dic={}
for i in range(n):
line=raw_input().split()
dic[line[0]]=sum(map(float,line[1:]))/3.0
print '%.2f' % dic[raw_input()]
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input()
if query_name in student_marks:
x = ((float(student_marks[query_name][0]) + float(student_marks[query_name][1]) + float(student_marks[query_name][2])) / 3)
print('%.2f' % x)
# Enter your code here. Read input from STDIN. Print output to STDOUT
d={}
for _ in range(int(raw_input())):
item = raw_input().split()
name = item[0]
grade = [float(a) for a in item[1:]]
d[name] = grade
request = raw_input().strip()
avg = reduce(lambda x, y: x + y, d[request])/len(d[request])
print '%.2f' %(avg)
# Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(input())
c = 1
students = {}
while c <= n :
line = input()
inList = line.split()
students[inList[0]] = inList[1:4]
c += 1
student = input()
sum = 0
for gs in students[student]:
sum = sum + float(gs)
print('{0:.2f}'.format(sum / 3))
In our experience, we suggest you solve this Finding the Percentage Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Finding the Percentage Hacker Rank Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Finding the Percentage Hacker Rank Solution.
I hope this Finding the Percentage Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Staircase Hacker Rank Solution
A Very Big Sum Hacker Rank Solution