livepython.net

79. Python Program to Make a Class Marks Report

HardList tools

Overview

Put the whole chapter together: build a list from input, sort it, index it, slice it and use min(), max(), sum() and len().

Problem Statement

Read the marks of five students (whole numbers), one per line, into a list. Sort the list from smallest to largest, then print six lines: the sorted list, the highest mark, the lowest mark, the average with 2 decimal places, the middle mark (the item in the middle of the sorted list), and the three highest marks from biggest to smallest. For example, for 78, 55, 100, 62 and 90:

Sorted: [55, 62, 78, 90, 100]
Highest: 100
Lowest: 55
Average: 77.00
Middle mark: 78
Top 3: [100, 90, 78]

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order. Example:

78
55
100
62
90

Output

The output for that example:

Sorted: [55, 62, 78, 90, 100]
Highest: 100
Lowest: 55
Average: 77.00
Middle mark: 78
Top 3: [100, 90, 78]

The tests try 4 different inputs.

Learn this firstChapter 9 · Python List Functions: in, sort, min, max, sum
solution.py
# write your code here

EXPECTED OUTPUT

1Sorted: [55, 62, 78, 90, 100]
2Highest: 100
3Lowest: 55
4Average: 77.00
5Middle mark: 78
6Top 3: [100, 90, 78]

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.