Grade book report

For each student, print the name, the average of three marks with one decimal, and a grade: A+ for 80 or more, A for 70 or more, B for 60 or more, otherwise C.

What to build

One line of a report for each student.

Requirements

  • Work out each student's average of three marks.
  • Print the name, the average with one decimal and the grade.

Input

The first line has n (1 to 100). Each of the next n lines is a name and three marks from 0 to 100.

Output

One line per student: NAME AVERAGE GRADE, separated by single spaces.

Constraints

n is from 1 to 100, and marks are from 0 to 100.

Example

Input:

2
Rahim 72 68 80
Nadia 91 88 95

Output:

Rahim 73.3 A
Nadia 91.3 A+

Why it works

The grade depends on the exact average, so a separate function can compare it without any rounding getting in the way.

Examples

Example 1 · Input
2
Rahim 72 68 80
Nadia 91 88 95
Expected output
Rahim 73.3 A
Nadia 91.3 A+
Example 2 · Input
1
Karim 55 61 70
Expected output
Karim 62.0 B

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

parts[0] is the name; parts[1:] are the marks.

Hint 2

Check the highest grade first.

Solution

Show one correct solution (try it yourself first)
def grade(avg):
    if avg >= 80:
        return "A+"
    if avg >= 70:
        return "A"
    if avg >= 60:
        return "B"
    return "C"

n = int(input())
for _ in range(n):
    parts = input().split()
    marks = [int(m) for m in parts[1:]]
    avg = sum(marks) / len(marks)
    print(parts[0], f"{avg:.1f}", grade(avg))

Lesson: Project: a grade book →