Generation

generate functionMon, 16 Jan 2023

create calculator

def calculate(operator, num1, num2): if operator == 'add': return num1 + num2 elif operator == 'sub': return num1 - num2 elif operator == 'mul': return num1 * num2 elif operator == 'div': return num1 / num2 else: return 'Invalid operator' calculate('add', 1, 2)

Questions about programming?Chat with your personal AI assistant