writing the four functions for add,subtract,multiply, divide. i would like to write a universal function that takes two operands and operator arguments and return the result for the expression def universal(operand1,operand2,operator): .how would i deal with the return expression?
what do you expect the return should be?
do it..ask for userinput for operator
I've a suggestion for you.. Create a universal function and do the following... Pass the arguments in the order you want.. Like - number, number, operator (4,4, +) Then inside the universal function change the order to - Number, operator, number (4 + 4) And use eval() inside the universal function... Pass the modified argument order as a string to eval and you will get your result.
Обсуждают сегодня