#C12894. Analyze Numbers Statistics
Analyze Numbers Statistics
Analyze Numbers Statistics
You are given a list of integers. Your task is to compute two results:
- The sorted list of integers in ascending order.
- A statistics dictionary containing the following keys:
- (\text{mean}): the average of the numbers, always displayed with one decimal place.
- (\text{median}): the middle value if the number of elements is odd, or the average of the two middle values if even (displayed with one decimal if necessary, except when it is an integer in the odd case).
- (\text{mode}): the number that appears most frequently. In the case of a tie, choose the one that appears first in sorted order.
If the input list is empty, output an empty list and an empty dictionary.
Input is provided via standard input (stdin) as a single line of space-separated integers. The output should be printed to standard output (stdout) in two lines. The first line is the sorted list in Python list format, and the second line is the statistics dictionary in Python dictionary format.
Examples: Input: 4 1 2 2 5 4 7 8 8 8 Output: [1, 2, 2, 4, 4, 5, 7, 8, 8, 8] {'mean': 4.9, 'median': 4.5, 'mode': 8}
Input: 10 Output: [10] {'mean': 10.0, 'median': 10, 'mode': 10}
Input: (empty) Output: [] {}
inputFormat
A single line containing space-separated integers via standard input. An empty line represents an empty list.
outputFormat
Print two lines to standard output:
- The first line is the sorted list of integers in Python list format.
- The second line is a dictionary with keys 'mean', 'median', and 'mode'. Floating-point numbers should be formatted appropriately (mean always with one decimal).## sample
4 1 2 2 5 4 7 8 8 8
[1, 2, 2, 4, 4, 5, 7, 8, 8, 8]
{'mean': 4.9, 'median': 4.5, 'mode': 8}
</p>