Generation

generate functionFri, 27 Jan 2023

Write an arithmetic function that takes 3 arguments: the first 2 are numbers, the third is the operation to be performed on them. If the third argument is +, add them up; if -, then subtract; * - will multiply

def arithmetic(a, b, operation): if operation == '+': return a + b elif operation == '-': return a - b elif operation == '*': return a * b arithmetic(1, 2, '+')

Questions about programming?Chat with your personal AI assistant