Finding the percentage - Hackerrank Solution

 

Finding the Percentage


Objective:


The provided code stub will 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.


Solution:

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()
    l=list(student_marks[query_name])
    le=len(l)
    s=sum(l)
    av=s/le
    print('%.2f'%av)


Note:

This Code is Verified by all Test Cases.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

 The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You. 


Finding the percentage - Hackerrank Solution Finding the percentage - Hackerrank Solution Reviewed by CodexRitik on March 24, 2020 Rating: 5

No comments:

Powered by Blogger.