Solution 1

``````class Calculator(object):
def __init__(self):
pass

return num1 + num2

def subtract(self, num1, num2):
return num1 - num2

def multiply(self, num1, num2):
return num1 * num2

def divide(self, num1, num2):
return float(num1) / num2
``````

# OOP Calculator

The objective of the following assignment is to build a simple calculator using Object Oriented Programming.

This is the interface it should follow:

``````calculator = Calculator()

calculator.subtract(8, 1)  # 7
calculator.multiply(3, 5)  # 15
calculator.divide(5, 2)  # 2.5
``````

### Test Cases

test divide -

``````def test_divide():
calc = Calculator()
assert calc.divide(9, 3) == 3.0
``````

test multiply -

``````def test_multiply():
calc = Calculator()
assert calc.multiply(7, 9) == 63
``````

``````def test_add():
calc = Calculator()
``````

test divide decimal -

``````def test_divide_decimal():
calc = Calculator()
assert calc.divide(9, 2) == 4.5
``````

test subtract -

``````def test_subtract():
calc = Calculator()
assert calc.subtract(5, 2) == 3
``````
class Calculator(object): pass