File size: 544 Bytes
3060e5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class CalculatorAgent:
    def calculate(self, operation: str, x: str, y: str) -> float:
        operation = operation.lower().strip()

        x = float(x)
        y = float(y)
        if operation == "add":
            return x + y
        elif operation == "subtract":
            return x - y
        elif operation == "multiply":
            return x * y
        elif operation == "divide":
            if y == 0:
                return "Cannot divide by zero"
            return x / y
        else:
            return "Unknown operation"