17 lines
644 B
Python
17 lines
644 B
Python
import decimal
|
|
|
|
from comprehension_history import DIMENSIONS, FLOOR
|
|
|
|
|
|
def means(lines: list[list[str]]) -> list[decimal.Decimal]:
|
|
"""The mean of each score across the lines, in DIMENSIONS' order, rounded half up to two decimals."""
|
|
return [mean([decimal.Decimal(score) for score in column]) for column in zip(*lines)]
|
|
|
|
|
|
def mean(values: list[decimal.Decimal]) -> decimal.Decimal:
|
|
return (sum(values, decimal.Decimal(0)) / len(values)).quantize(decimal.Decimal("0.01"), decimal.ROUND_HALF_UP)
|
|
|
|
|
|
def under_floor(found: list[decimal.Decimal]) -> list[str]:
|
|
return [f"{name} {value}" for name, value in zip(DIMENSIONS, found) if value < FLOOR]
|