A weather station has many sensors, and the dashboard shows one line of text for each. Write summary_line(label, readings) that builds that line.
readings is a list of numbers, where None means the sensor missed that reading. A reading of 0 is a real measurement (zero degrees) and must be counted. The line has exactly this shape:
<label>: <count> readings, <share> present, mean <mean>
<count>is the total number of entries inreadings(including the missing ones), with a comma as thousands separator (1,500);<share>is the fraction of entries that are notNone, as a percentage with one decimal (75.0%);<mean>is the mean of the readings that are present, with exactly two decimals (8.50), or the textn/aif none are present.
The helper sensor_log(n, seed) returns n random whole-degree readings with some gaps and some zeros.
Examples
Input: label = "north", readings = [12.5, None, 13.0, 0]
Output: "north: 4 readings, 75.0% present, mean 8.50"
Explanation: three of the four entries are present; (12.5 + 13.0 + 0) / 3 = 8.5.
Input: label = "roof", readings = [None, None]
Output: "roof: 2 readings, 0.0% present, mean n/a"
Constraints
1 <= len(readings) <= 10**5- the result does not depend on randomness or the clock
Goals
- Format counts, percentages and decimals with :, and :.1% and :.2f
- Tell a missing value (None) apart from a genuine zero