Skip to content

Commit

Permalink
Multiplication support
Browse files Browse the repository at this point in the history
We decided to just implment two-argument
multiplication, because users don't need anything
more complicated yet
  • Loading branch information
mike-north committed Feb 8, 2021
1 parent a5fe01a commit 6d7000f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ def sub(a, b):
```
"""
return a - b


def mult(a, b):
"""
Multiply some numbers
```py
mult(8, 3) # 24
```
"""
return a * b
6 changes: 5 additions & 1 deletion src/calc_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from calc import add, sub
from calc import add, sub, mult

class TestStringMethods(unittest.TestCase):

Expand All @@ -11,5 +11,9 @@ def test_sub_2arg(self):
# Make sure 4 - 3 = 1
self.assertEqual(sub(4, 3), 1, 'subtracting three from four')

def test_mult_2arg(self):
# Make sure 4 * 3 = 12
self.assertEqual(mult(4, 3), 12, 'multiplying three and four')

if __name__ == '__main__':
unittest.main()
1 change: 0 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def main():
x = add(3, sub(7, 2))
x = x/2
return x

print('Result = {}'.format(main()))

0 comments on commit 6d7000f

Please sign in to comment.