HackerRank- Python Finding the Percentage




You have a record of N 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 N followed by the names and marks for N 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.



  1. if __name__ == '__main__':
  2. n = int(input())
  3. marks = {}
  4. for _ in range(n):
  5. name, *line = input().split()
  6. scores = list(map(float, line))
  7. scores=sum(scores)/3
  8. marks[name] = scores
  9. a = input()
  10. print('%.2f' % marks[a])




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube