Question: I need unique python code for this question: Complete the below function which takes as argument a filename WITHOUT the extension and reads the file
I need unique python code for this question:

Complete the below function which takes as argument a filename WITHOUT the extension and reads the file "filename.in" line by line. Each line of this file contains a mathematical operation. You must split the data in the line by space characters, perform the given operation and write the result to "filename.out" using standart mathematical notation. Assume that only the following four operations are available: ADD = Addition, SUB = Subtraction, MUL = Multiplication, POW = Power. If you detect an operation other than these you should write the message "Invalid Operation" to file. You can also assume that the input file always exists. You can also assume that all operands are integers. Example: === contents of "filename.in ADD 34 56 SUB 30 13 MUL 3 7 POW 2 5 CHK 34 === contents of "filename.out" 34 + 56 = 90 30 - 13 = 17 3 * 7 = 21 25 = 32 Invalid Operation def file_math(filename): return # Remove this line only when you answer this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
