The problem at hand involves calculating the average score of a student. The program receives the number of students, their names, and their scores as input. It then calculates the average score for a specific student whose name is queried.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The solution works by first taking the number of students as input. It then enters a loop where it takes the name of each student and their scores as input. These details are stored in a dictionary where the student's name is the key and their scores are the values. After all the student details have been entered, the program takes the name of a student as input and calculates their average score by summing up their scores and dividing by the number of scores. The average score is then printed out with a precision of two decimal places.
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()
avg_score = sum(student_marks[query_name]) / len(student_marks[query_name])
print(f"{avg_score:.2f}")
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.