In python Write a function definition for a function called calc which has 3 integer parameters

In python Write a function definition for a function called calc which has 3 integer parameters

In python

Write a function definition for a function called calc which has 3 integer parameters. The parameters represent two operands and a choice for operator. Your function should determine which operation is requested, perform the operation and return the result. The operation choices are: 1 for add, 2 for subtract, 3 for multiply and 4 for divide. The function should not allow division by zero; it should return 0 instead. The function does no input from the keyboard nor output to the screen. Your function must use only one return statement.

Example: calc(2, 4, 1) would return 6 because 2 + 4 = 6 calc(10, 15, 2) would return -5 because 10-15 = -5 calc (3, 9, 3) would return 27 because 3*9 = 27
calc (15, 4, 4) would return 3.75 because 15/4 = 3.75
Powered by