Loading...
Loading...
Each record is name,score. The first input line is the number m of records. The next m lines are records.
A record is valid when it has exactly two parts and the score is a whole number from 0 to 100. Print Valid: <count>, then Rejected: <count>. If at least one record is valid, also print Average: <average with 2 decimals> and Top: <name> <score>, where the first record with the highest score wins. If no record is valid, print No valid records instead of the last two lines.
Example 1
Input
4 Asha,90 Ravi,x Meera,75 Tom
Output
Valid: 2 Rejected: 2 Average: 82.50 Top: Asha 90
Two valid records, two rejected.
Example 2
Input
2 A,200 B
Output
Valid: 0 Rejected: 2 No valid records
No valid record.
Try the problem first. Open one hint at a time.
Unpack the split into name and score_text. Raise ValueError yourself when the score is outside 0 to 100.
Keep a list of (score, name) pairs. Use the first record with the largest score, so compare with > and not >=.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor