How many passed?

Report how a class did.

What to build

A short report from a list of records.

Requirements

  • Read each NAME MARK line.
  • A mark of 40 or more is a pass.
  • Print Passed P of N, and then Rate R with one decimal and a percent sign.

Input

The first line has n. Each of the next n lines has a name and a mark.

Output

Two lines.

Constraints

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

Example

Input:

3
Rahim 72
Nadia 35
Karim 40

Output:

Passed 2 of 3
Rate 66.7%

Why it works

Counting as you read keeps the program to one loop, and the format code handles the percentage.

Examples

Example 1 · Input
3
Rahim 72
Nadia 35
Karim 40
Expected output
Passed 2 of 3
Rate 66.7%
Example 2 · Input
1
Mitu 39
Expected output
Passed 0 of 1
Rate 0.0%

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

Hints

Hint 1

Count the marks of 40 or more.

Hint 2

Use the .1% format code for the rate.

Solution

Show one correct solution (try it yourself first)
n = int(input())
passed = 0
for _ in range(n):
    name, mark = input().split()
    if int(mark) >= 40:
        passed += 1
print(f"Passed {passed} of {n}")
print(f"Rate {passed / n:.1%}")

Lesson: Project: a grade book →