From 7e4001c7293a8b4af41e8401405e6a809e770fe3 Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:30:34 -0600 Subject: [PATCH 1/6] Update calculator.py --- calculator.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/calculator.py b/calculator.py index a5c3aed..6cf25bd 100644 --- a/calculator.py +++ b/calculator.py @@ -4,37 +4,37 @@ """ # Should this function even be here? -def poorly_implemented_function_with_no_close_parenthesis( +def poorly_implemented_function_with_no_close_parenthesis(): def addition(x: int, y: int) -> int: """ Adds two numbers. - Note: `*` is the multiplication operator in Python. + Note: `+` is the addition operator in Python. Args: x (int): The first parameter. - y (str): The second parameter. + y (int): The second parameter. Returns: int: The sum of `x` and `y`. """ - return x * y + return x + y def multiplication(x: int, y: int) -> int: """ Multiplies two numbers. - Note: `+` is the addition operator in Python. + Note: `*` is the multiplication operator in Python. Args: x (int): The first parameter. - y (str): The second parameter. + y (int): The second parameter. Returns: int: The multiple of `x` and `y`. """ - return x + y + return x * y def division(x: int, y: int) -> int: """ @@ -44,9 +44,9 @@ def division(x: int, y: int) -> int: Args: x (int): The first parameter. - y (str): The second parameter. + y (int): The second parameter. Returns: int: `x` divided by `y`. """ - return x // y \ No newline at end of file + return x // y From 431caa7487b921e640a0149e86cb4ab8c8bcd258 Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:34:17 -0600 Subject: [PATCH 2/6] Update calculator.py --- calculator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/calculator.py b/calculator.py index 6cf25bd..a26047e 100644 --- a/calculator.py +++ b/calculator.py @@ -4,7 +4,6 @@ """ # Should this function even be here? -def poorly_implemented_function_with_no_close_parenthesis(): def addition(x: int, y: int) -> int: """ From 60d571f03ee294533fcd487127761a3bd2ba8be4 Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:39:15 -0600 Subject: [PATCH 3/6] Update calculator.py --- calculator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/calculator.py b/calculator.py index a26047e..3419bb9 100644 --- a/calculator.py +++ b/calculator.py @@ -48,4 +48,6 @@ def division(x: int, y: int) -> int: Returns: int: `x` divided by `y`. """ + if y == 0: + raise ValueError("You can not divide by 0" return x // y From 4ff3ebab327d772cbee272cfd518b32dfa61d0ad Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:41:08 -0600 Subject: [PATCH 4/6] Update calculator.py --- calculator.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/calculator.py b/calculator.py index 3419bb9..76b524c 100644 --- a/calculator.py +++ b/calculator.py @@ -1,16 +1,11 @@ - """ An extremely buggy Python math library . . . """ -# Should this function even be here? - def addition(x: int, y: int) -> int: """ Adds two numbers. - Note: `+` is the addition operator in Python. - Args: x (int): The first parameter. y (int): The second parameter. @@ -24,30 +19,29 @@ def multiplication(x: int, y: int) -> int: """ Multiplies two numbers. - Note: `*` is the multiplication operator in Python. - Args: x (int): The first parameter. y (int): The second parameter. Returns: - int: The multiple of `x` and `y`. + int: The product of `x` and `y`. """ return x * y def division(x: int, y: int) -> int: """ - Multiplies two numbers. - - Note: `//` is the *integer* division operator in Python. + Divides two numbers using integer division. Args: x (int): The first parameter. y (int): The second parameter. Returns: - int: `x` divided by `y`. + int: `x` divided by `y` (integer division). + + Raises: + ValueError: If `y` is zero. """ if y == 0: - raise ValueError("You can not divide by 0" + raise ValueError("Cannot divide by zero") return x // y From 05832f5c24392533ae0457feef69375e6f1b2c4a Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:44:29 -0600 Subject: [PATCH 5/6] Update calculator.py --- calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calculator.py b/calculator.py index 76b524c..e749df1 100644 --- a/calculator.py +++ b/calculator.py @@ -28,7 +28,7 @@ def multiplication(x: int, y: int) -> int: """ return x * y -def division(x: int, y: int) -> int: +def division(x: int, y: int) -> float: """ Divides two numbers using integer division. From b31841b1277881635ee29934c65ae925c6296728 Mon Sep 17 00:00:00 2001 From: ompatel277 <156952232+ompatel277@users.noreply.github.com> Date: Thu, 6 Feb 2025 19:01:34 -0600 Subject: [PATCH 6/6] Update calculator.py --- calculator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/calculator.py b/calculator.py index e749df1..e0f233a 100644 --- a/calculator.py +++ b/calculator.py @@ -30,18 +30,18 @@ def multiplication(x: int, y: int) -> int: def division(x: int, y: int) -> float: """ - Divides two numbers using integer division. + Divides two numbers. Args: x (int): The first parameter. y (int): The second parameter. Returns: - int: `x` divided by `y` (integer division). + float: The result of `x` divided by `y`. Raises: ValueError: If `y` is zero. """ if y == 0: raise ValueError("Cannot divide by zero") - return x // y + return x / y # Floating-point division