The first line contains the integer , the number of students' records. The next 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.ConstraintsOutput FormatPrint one line: The average of the marks obtained by the particular student correct to 2 decimal places.
Question
The first line contains the integer , the number of students' records. The next 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.ConstraintsOutput FormatPrint one line: The average of the marks obtained by the particular student correct to 2 decimal places.
Solution
It seems like you're asking for a Python solution to a problem where you have a list of student records and you want to find the average mark of a particular student. Here's a step-by-step solution:
- First, we need to get the number of student records. We can do this using the
input()function in Python, which reads a line of text from the user. Since this function returns a string, we need to convert this to an integer using theint()function.
n = int(input())
- Next, we need to read the student records. We can do this in a loop that runs
ntimes. In each iteration of the loop, we read a line of text, split it into a name and a mark, and store it in a dictionary.
records = {}
for _ in range(n):
name, *marks = input().split()
marks = list(map(float, marks))
records[name] = marks
- Then, we need to read the name of the student to query. We can do this using the
input()function again.
query_name = input()
- Finally, we need to compute and print the average mark of the queried student. We can do this by summing up the marks of the student (using the
sum()function) and dividing by the number of marks (using thelen()function). We use theformat()function to print the result with 2 decimal places.
average = sum(records[query_name]) / len(records[query_name])
print("{:.2f}".format(average))
This is the complete Python program:
n = int(input())
records = {}
for _ in range(n):
name, *marks = input().split()
marks = list(map(float, marks))
records[name] = marks
query_name = input()
average = sum(records[query_name]) / len(records[query_name])
print("{:.2f}".format(average))
Similar Questions
The first line contains an integer, , the number of students.The subsequent lines describe each student over lines.- The first line contains a student's name.- The second line contains their grade.ConstraintsThere will always be one or more students having the second lowest grade.Output FormatPrint the name(s) of any student(s) having the second lowest grade in. If there are multiple students, order their names alphabetically and print each one on a new line.
The only line contains space-separated integers, and .ConstraintsSample Input 05 4Sample Output 0233Explanation 0All possible values of and are:The maximum possible value of that is also is , so we print on first line.The maximum possible value of that is also is , so we print on second line.The maximum possible value of that is also is , so we print on third line.
Enter the student details using constructors with arguments. Then find the total marks of each student. If it is greater than 500 print pass ,else print fail.
The first line contains a string, .The second line contains the width, .ConstraintsSample Input 0ABCDEFGHIJKLIMNOQRSTUVWXYZ4Sample Output 0ABCDEFGHIJKLIMNOQRSTUVWXYZ
Akulya has received her semester results. The performance in the exam is graded with letters S, A, B, C, D, E, and F. Help her to understand the mark range for a grade with respect to the mark obtained in the exam . Input FormatRead the course nameRead the markOutput FormatPrint the course namePrint the markPrint the GradeSample InputICSE102L89Sample OutputICSE102L89A GradeInput
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.