From 02c4f086a164be6f2d582a014cdf740a9ccdf96f Mon Sep 17 00:00:00 2001 From: dhruvakidadumbe Date: Sat, 27 Dec 2025 22:18:57 +0530 Subject: [PATCH 1/5] Add docstring to palindrome function --- strings/palindrome.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/strings/palindrome.py b/strings/palindrome.py index e765207e5942..fa44a9797a25 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -19,6 +19,11 @@ def is_palindrome(s: str) -> bool: + """ + Check whether a given string is a palindrome. + + :param s: input string + :return: True if palindrome, False otherwise """ Return True if s is a palindrome otherwise return False. From 9cb62db7d913cb47ab441424fe8ee5d7f8aa9cc3 Mon Sep 17 00:00:00 2001 From: dhruvakidadumbe Date: Sat, 27 Dec 2025 22:21:30 +0530 Subject: [PATCH 2/5] Add docstring to palindrome function --- strings/palindrome.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/strings/palindrome.py b/strings/palindrome.py index fa44a9797a25..2308607765bf 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -25,12 +25,7 @@ def is_palindrome(s: str) -> bool: :param s: input string :return: True if palindrome, False otherwise """ - Return True if s is a palindrome otherwise return False. - - >>> all(is_palindrome(key) is value for key, value in test_data.items()) - True - """ - + start_i = 0 end_i = len(s) - 1 while start_i < end_i: From cf82a853983639daabe4a7bf8a86d5be03b190fc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 27 Dec 2025 16:58:52 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/palindrome.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/strings/palindrome.py b/strings/palindrome.py index 2308607765bf..f4e88c516733 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -21,11 +21,11 @@ def is_palindrome(s: str) -> bool: """ Check whether a given string is a palindrome. - + :param s: input string :return: True if palindrome, False otherwise """ - + start_i = 0 end_i = len(s) - 1 while start_i < end_i: From 2a695ffb49ab82f5571c8249e7726a7067d2950e Mon Sep 17 00:00:00 2001 From: dhruvakidadumbe Date: Sat, 27 Dec 2025 22:37:55 +0530 Subject: [PATCH 4/5] Add input validation and docstring to factorial function --- maths/factorial.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/maths/factorial.py b/maths/factorial.py index ba61447c7564..99c8988949c9 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -5,25 +5,13 @@ def factorial(number: int) -> int: """ - Calculate the factorial of specified number (n!). + + Calculate the factorial of a non-negative integer. - >>> import math - >>> all(factorial(i) == math.factorial(i) for i in range(20)) - True - >>> factorial(0.1) - Traceback (most recent call last): - ... - ValueError: factorial() only accepts integral values - >>> factorial(-1) - Traceback (most recent call last): - ... - ValueError: factorial() not defined for negative values - >>> factorial(1) - 1 - >>> factorial(6) - 720 - >>> factorial(0) - 1 + :param n: non-negative integer + :return: factorial of n + :raises ValueError: if n is negative + """ if number != int(number): raise ValueError("factorial() only accepts integral values") From 2f1cb5fcbc4857158663c3e10a5e2f87d0324cf3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:42:04 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/factorial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/factorial.py b/maths/factorial.py index 99c8988949c9..9082ad241dc3 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -5,13 +5,13 @@ def factorial(number: int) -> int: """ - + Calculate the factorial of a non-negative integer. :param n: non-negative integer :return: factorial of n :raises ValueError: if n is negative - + """ if number != int(number): raise ValueError("factorial() only accepts integral values")