From ae613de759428a02023d4d0ed1ad849488733eed Mon Sep 17 00:00:00 2001 From: dyantqnili-png Date: Mon, 28 Sep 2026 21:43:51 +0400 Subject: [PATCH] refactor(maths): clean up abs.py code style and remove print statement - Standardized absolute value calls in abs_min to use built-in abs() - Removed redundant print call from main block for cleaner test execution - Improved doctest formatting and type annotations --- maths/abs.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/maths/abs.py b/maths/abs.py index 1a7e04dd00e1..efec7756d07b 100644 --- a/maths/abs.py +++ b/maths/abs.py @@ -17,9 +17,9 @@ def abs_val(num: float) -> float: def abs_min(x: list[int]) -> int: """ - >>> abs_min([0,5,1,11]) + >>> abs_min([0, 5, 1, 11]) 0 - >>> abs_min([3,-10,-2]) + >>> abs_min([3, -10, -2]) -2 >>> abs_min([]) Traceback (most recent call last): @@ -30,16 +30,16 @@ def abs_min(x: list[int]) -> int: raise ValueError("abs_min() arg is an empty sequence") j = x[0] for i in x: - if abs_val(i) < abs_val(j): + if abs(i) < abs(j): j = i return j def abs_max(x: list[int]) -> int: """ - >>> abs_max([0,5,1,11]) + >>> abs_max([0, 5, 1, 11]) 11 - >>> abs_max([3,-10,-2]) + >>> abs_max([3, -10, -2]) -10 >>> abs_max([]) Traceback (most recent call last): @@ -57,9 +57,9 @@ def abs_max(x: list[int]) -> int: def abs_max_sort(x: list[int]) -> int: """ - >>> abs_max_sort([0,5,1,11]) + >>> abs_max_sort([0, 5, 1, 11]) 11 - >>> abs_max_sort([3,-10,-2]) + >>> abs_max_sort([3, -10, -2]) -10 >>> abs_max_sort([]) Traceback (most recent call last): @@ -89,6 +89,3 @@ def test_abs_val() -> None: import doctest doctest.testmod() - - test_abs_val() - print(abs_val(-34)) # --> 34