From 73e99171db69fc922f25171670022cd3269fa5b8 Mon Sep 17 00:00:00 2001 From: prachi757 Date: Wed, 16 Jul 2025 16:09:19 +0530 Subject: [PATCH 1/2] Add last_digit function with type hints and doctests --- maths/last_digit.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 maths/last_digit.py diff --git a/maths/last_digit.py b/maths/last_digit.py new file mode 100644 index 000000000000..c3a7e4c32383 --- /dev/null +++ b/maths/last_digit.py @@ -0,0 +1,12 @@ +def last_digit(n: int) -> int: + """ + Return the last digit of a given integer. + + >>> last_digit(1234) + 4 + >>> last_digit(-98) + 8 + >>> last_digit(0) + 0 + """ + return abs(n) % 10 From f5ee99e95be7922b9a3c750a3be02254445460eb Mon Sep 17 00:00:00 2001 From: prachi757 Date: Wed, 16 Jul 2025 19:32:45 +0530 Subject: [PATCH 2/2] Update parameter name to 'number' in last_digit function --- maths/last_digit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/last_digit.py b/maths/last_digit.py index c3a7e4c32383..9309a0722833 100644 --- a/maths/last_digit.py +++ b/maths/last_digit.py @@ -1,4 +1,4 @@ -def last_digit(n: int) -> int: +def last_digit(number: int) -> int: """ Return the last digit of a given integer. @@ -9,4 +9,4 @@ def last_digit(n: int) -> int: >>> last_digit(0) 0 """ - return abs(n) % 10 + return abs(number) % 10