From 3a427e98b3fa78cce6f2295f6bd4964ba5f31485 Mon Sep 17 00:00:00 2001 From: Andrew Emelyaneko Date: Mon, 28 Sep 2026 15:41:51 +0300 Subject: [PATCH] feat: add min/max operations to calculator --- pipeline_test.py | 8 ++++++-- test_pipeline.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pipeline_test.py b/pipeline_test.py index 39fe177..e502b96 100644 --- a/pipeline_test.py +++ b/pipeline_test.py @@ -1,7 +1,7 @@ """A small arithmetic calculator. Provides the :func:`calculate` function which performs basic arithmetic -operations (+, -, *, /, **, ^, //, %) with proper error handling. +operations (+, -, *, /, **, ^, //, %, min, max) with proper error handling. """ __all__ = ["calculate"] @@ -17,7 +17,7 @@ def calculate(a: float, op: str, b: float) -> int | float: Args: a: First operand - op: Operation (+, -, *, /, **, ^, //, %) + op: Operation (+, -, *, /, **, ^, //, %, min, max) b: Second operand Returns: @@ -56,5 +56,9 @@ def calculate(a: float, op: str, b: float) -> int | float: return a // b case "%": return a % b + case "min": + return min(a, b) + case "max": + return max(a, b) case _: raise ValueError(f"unknown operation: {op!r}") diff --git a/test_pipeline.py b/test_pipeline.py index 6b5ef74..2095071 100644 --- a/test_pipeline.py +++ b/test_pipeline.py @@ -16,6 +16,8 @@ from pipeline_test import calculate (2, "^", 3, 8), (7, "//", 2, 3), (7, "%", 2, 1), + (3, "min", 7, 3), + (3, "max", 7, 7), ], ) def test_operations(a, op, b, expected):