123. Python Program to Print a Marks Report from a List of Tuples
MediumUnpacking
Overview
Read pairs into a list of tuples, then unpack them in a for loop to make a report.
Problem Statement
Read lines until the user types done. Each line has a name and whole-number marks, separated by a space, like Sunny 82. Store each student as a tuple (name, marks) in a list.
Then, for each student in the order they were typed, print the name, the marks and Pass (40 or more) or Fail. Last, print the student with the highest marks. If two students share the highest marks, print the one typed first. For example:
Sunny: 82 Pass
Rocky: 35 Fail
Lucky: 91 Pass
Top: Lucky (91)
If the first line is already done, print only:
No students
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One student per line; the last line is always done. Example:
Sunny 82
Rocky 35
Lucky 91
done
Output
The output for that example:
Sunny: 82 Pass
Rocky: 35 Fail
Lucky: 91 Pass
Top: Lucky (91)
The tests try 4 different inputs.