Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Math:
- def __init__(self, a, b, operator):
- self.a = a
- self.b = b
- self.operator = operator
- def make_calculations(self):
- if self.operator == "+":
- return self._add(self.a, self.b)
- elif self.operator == "-":
- return self._subtract(self.a, self.b)
- # Helper methods for the class
- def _add(self, x, y):
- return x + y
- def _subtract(self, x, y):
- return x - y
- obj = Math(10, 5, "+")
- print(obj.make_calculations())
- obj = Math(10, 5, "-")
- print(obj.make_calculations())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement