Score Calculator

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

In this programming problem, given the scores of five different subjects for k different students, you are required to write a function named average that returns a list of the average score for each subject.

You can start with this template code and ensure your code can run correctly within this template:

from statistics import mean # you may use this function to find the average of a list of number

def average(scores):
    # your code here

# Note that the following code is for local testing purposes only. You should leave this part of code unchanged and not submit it to the OJ system.
T = int(input())
for t in range(T):
    k = int(input())
    scores = [map(int, input().split()) for _ in range(k)]
    avers = average(scores)
    for m in avers:
        print(f'{m:.2f}', end=' ')
    print()

Please note that you only have to submit the definition of the average function to the OJ system along with the import statement if you used the module. The rest of the code is for your local testing purposes only.

Input Specification

The first line of the input gives the number of test cases, T, and then T test cases follow.

For each test case, it will consist of k+1 lines. The first line consists of a number k, which represents the number of students. After that, k lines follow. Each line contains 5 integers, indicating the scores for five different subjects.

Constraints

1 \leq T \leq 100

1 \leq k \leq 100

Output Specification

For each test case, output a single line containing 5 numbers indicate the average score for five different subjects respectively.

Sample Input

1
3
90 80 70 60 50
50 60 70 80 90
80 80 80 80 80

Sample Output

73.33 73.33 73.33 73.33 73.33

Explanation

The 1 on the first line means one test cases follow.

The 3 on the second line means three are 3 students ( k = 3 ).

For the third line, it represents the first student got 90 on \text{subject}_1, 80 on \text{subject}_2, and so on.

For the fourth line, it represents the second student got 50 on \text{subject}_1, 60 on \text{subject}_2, and so on.

For the fifth line, it represents the third student got 80 on \text{subject}_1, 80 on \text{subject}_2, and so on.

So the output of this test case should be 73.33 73.33 73.33 73.33 73.33 which represent five average scores of five different subjects.

Hint

zip mean


Comments

There are no comments at the moment.