diff --git a/calculator/operators.py b/calculator/operators.py index 5b643ab13bdad39d1d359035b72b2ba0284c7377..3766bdd75814c63c10cd9f976889dbabc9818e8e 100644 --- a/calculator/operators.py +++ b/calculator/operators.py @@ -1,10 +1,13 @@ """ Operator module contains the Operator class and a list of standard operators. """ + + class Operator: """ Operator class is a binary operator with a symbol, a precedence and an evaluation function. """ + def __init__(self, symbol, precedence, evaluate_function): self.symbol = symbol self.precedence = precedence @@ -17,4 +20,5 @@ class Operator: return self.evaluate_function(left, right) -STANDARD_OPERATORS = { '+': Operator('+', 1, lambda a, b: a + b),'-': Operator('-', 1, lambda a, b: a - b),'*': Operator('×', 2, lambda a, b: a * b),'/': Operator('/', 2, lambda a, b: a / b)} +STANDARD_OPERATORS = {'+': Operator('+', 1, lambda a, b: a + b), '-': Operator('-', 1, lambda a, + b: a - b), '*': Operator('×', 2, lambda a, b: a * b), '/': Operator('/', 2, lambda a, b: a / b)}