feat: Add an average function to the calculator #12

Merged
typosaurus merged 2 commits from typosaurus/11-add-an-average-function-to-the-calculator into main 2026-07-26 22:13:17 +02:00
Showing only changes of commit 3ad3dc517f - Show all commits

View File

@ -25,6 +25,12 @@ def clamp_to_byte(value: int) -> int:
return max(0, min(255, value))
def average(values: list[int | float]) -> float:
if not values:
raise ValueError
return sum(values) / len(values)
def variance(values: Sequence[float]) -> float:
if not values:
raise ValueError
@ -37,5 +43,3 @@ def percentage(value: Union[int, float], total: Union[int, float]) -> float:
raise ValueError
return (value / total) * 100