def calculator(operator, num1, num2):
    if operator == '+':
        return num1 + num2
    elif operator == '-':
        return num1 - num2
    elif operator == '*':
        return num1 * num2
    elif operator == '/':
        return num1 / num2
    else:
        return "Invalid operator"

# Example usage
print(calculator('+', 5, 3))  # 8
print(calculator('-', 2, 7.3))  # 5
print(calculator('*', 4, 6))  # 24
print(calculator('/', 7, 5))  # 5.0
print(calculator('%', 5, 2))  # Invalid operator

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: