feat(nadia): Implement percentage function in calculator.py
Outcome: done Changed: src/calculator.py:1 (import Union), src/calculator.py:31-34 (percentage function) Verified by: `make verify` — exit 0, all 16 tests passed, compilation clean Findings: src/calculator.py:31-34 — percentage(value: Union[int, float], total: Union[int, float]) -> float added, returning (value/total)*100, raising ValueError on total==0 Open: none Confidence: high — all acceptance criteria met, verification passed Typosaurus-Run: ff52a86851934fd293e2f4493c5a9a46 Typosaurus-Node: baf30844321745fb8a1aabe91a33823b Typosaurus-Agent: @nadia Refs: #16
This commit is contained in:
parent
078766216d
commit
75400851c8
@ -1,5 +1,8 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from typing import Union
|
||||
|
||||
|
||||
def add(left: int, right: int) -> int:
|
||||
return left + right
|
||||
|
||||
@ -20,3 +23,11 @@ def clamp(value: int, low: int, high: int) -> int:
|
||||
|
||||
def clamp_to_byte(value: int) -> int:
|
||||
return max(0, min(255, value))
|
||||
|
||||
|
||||
def percentage(value: Union[int, float], total: Union[int, float]) -> float:
|
||||
if total == 0:
|
||||
raise ValueError
|
||||
return (value / total) * 100
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user