From 7c4c2b6914e949e504518a2944bb84741ebd9e5f Mon Sep 17 00:00:00 2001 From: Jonathan Gross Date: Thu, 30 Nov 2023 13:31:56 -0800 Subject: [PATCH 1/2] BUGFIX: 3-arg subtraction was not implemented --- src/calc_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calc_test.py b/src/calc_test.py index 2911910..e6638c8 100644 --- a/src/calc_test.py +++ b/src/calc_test.py @@ -17,6 +17,8 @@ def test_sub_2arg(self): # Make sure 4 - 3 = 1 self.assertEqual(sub(4, 3), 1, 'subtracting three from four') + def test_sub_3arg(self): + self.assertEqual(sub(4, 3, 1), 0, 'subtracting three and one from four') if __name__ == '__main__': unittest.main() From f1d0b129ba12304cf98d7e6402065becb889b888 Mon Sep 17 00:00:00 2001 From: jjgross77 <152453700+jjgross77@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:47:30 -0800 Subject: [PATCH 2/2] Update calc.py Adding support for 3rd arg --- src/calc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calc.py b/src/calc.py index 2af3c17..8511ae9 100644 --- a/src/calc.py +++ b/src/calc.py @@ -9,7 +9,7 @@ def add(a, b, third_operand = 0): """ return a + b + third_operand -def sub(a, b): +def sub(a, b, c = 0): """ Subtract some numbers @@ -17,4 +17,4 @@ def sub(a, b): sub(8, 3) # 5 ``` """ - return a - b + return a - b - c