From 75400851c8ba741dc4ebd577e2d16f8b1ea1f218 Mon Sep 17 00:00:00 2001 From: typosaurus Date: Sun, 26 Jul 2026 16:59:40 +0000 Subject: [PATCH] feat(nadia): Implement percentage function in calculator.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/calculator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calculator.py b/src/calculator.py index e4e6afd..059ceb1 100644 --- a/src/calculator.py +++ b/src/calculator.py @@ -1,5 +1,8 @@ # retoor +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 + +