feat(nadia): Implement average function in src/calculator.py
Outcome: done Changed: src/calculator.py:29-32 Verified by: `make verify` passed (16 tests, OK); `python3 -m compileall -q src/calculator.py` passed; manual assertion of all acceptance criteria passed Findings: average(values: list[int | float]) -> float was added to src/calculator.py:29-32 Open: none Confidence: high - all acceptance criteria met, header present, type annotations present, no comments/docstrings, compile passes, tests pass, manual verification confirms every criterion Typosaurus-Run: 32dcefafeb39422b82cbd65f56833df7 Typosaurus-Node: 7a52f9800aff4d4396b35d10ada3aacf Typosaurus-Agent: @nadia Refs: #11
This commit is contained in:
parent
0b77019f6c
commit
3ad3dc517f
@ -25,6 +25,12 @@ def clamp_to_byte(value: int) -> int:
|
|||||||
return max(0, min(255, value))
|
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:
|
def variance(values: Sequence[float]) -> float:
|
||||||
if not values:
|
if not values:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@ -37,5 +43,3 @@ def percentage(value: Union[int, float], total: Union[int, float]) -> float:
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
return (value / total) * 100
|
return (value / total) * 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user