Ad
Code
Diff
  • def calculator(num1,num2, operation):
        return {
            "m": num1 * num2,
            "a": num1 + num2,
            "s": num1 - num2,
            "d": num1 / num2,
        }[operation.lower()]
    
    • def calculator(num1,num2, charOperation):
    • answer = 0
    • if operation in ["m","M"]:
    • answer = num1*num2
    • elif operation in ["a","A"]:
    • answer = num1 + num2
    • elif operation in ["s", "S"]:
    • answer = num1 - num2
    • elif operation in ["d","D"]:
    • answer = num1 / num2
    • return answer
    • def calculator(num1,num2, operation):
    • return {
    • "m": num1 * num2,
    • "a": num1 + num2,
    • "s": num1 - num2,
    • "d": num1 / num2,
    • }[operation.lower()]