Testing

def calculator(num1, num2, operation): if operation == "add": return num1 + num2 elif operation == "subtract": return num1 - num2 elif operation == "multiply": return num1 * num2 elif operation == "divide": if num2 != 0: return num1 / num2 else: return "Error: Division by zero!" else: return "Invalid operation!" # Example usage: print(calculator(10, 5, "add")) # ➝ 15 print(calculator(10, 5, "subtract")) # ➝ 5 print(calculator(10, 5, "multiply")) # ➝ 50 print(calculator(10, 5, "divide")) # ➝ 2.0

Leave a Reply

Your email address will not be published. Required fields are marked *