From b2e44364536dea70bac2e97baec7d264daeaddfe Mon Sep 17 00:00:00 2001 From: Tam Nguyen Date: Tue, 16 Aug 2022 11:46:15 -0700 Subject: [PATCH 1/2] BUGFIX: 3-arg subtraction was not implemented The following change allows use of sub like ```py sub(5, 4, 1) #0 ``` We promised customers that we would have this in our initial release, so this is a bug, not an enhancement --- src/calc_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calc_test.py b/src/calc_test.py index 2911910..6af282b 100644 --- a/src/calc_test.py +++ b/src/calc_test.py @@ -17,6 +17,9 @@ 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 bc44f0380145d5d9b1818e8bf4e061cb4db7322a Mon Sep 17 00:00:00 2001 From: Tam Nguyen <28994173+mtwynn@users.noreply.github.com> Date: Tue, 16 Aug 2022 12:04:14 -0700 Subject: [PATCH 2/2] Add third argument for subtraction --- src/calc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calc.py b/src/calc.py index 2af3c17..f66baf0 100644 --- a/src/calc.py +++ b/src/calc.py @@ -9,12 +9,12 @@ 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 ```py - sub(8, 3) # 5 + sub(8, 3, 10) # -5 ``` """ - return a - b + return a - b - c