Create a function that will take a file name as an argument…….solved




5/5 - (2 votes)

In Python
Part 1 : 40 pts Create a function that will take a file name as an argument. This function should open the file associated with that file name and read each line of that file. Each line should be appended to a list and the function should return that list. The list returned should have an element for each line of the file and that element should be the string that is at that line in the file.
Part 2 : 40 pts Create a function that will accept a list of strings. Each string in this list will contain a series of mathematical operations with numbers and operators separated by spaces. For example, “1 + 4 – 3”. For each element of the list your code should split the string into each of it’s parts and complete the mathematical operation for that string. It should then write the result of that operation to an output file.Each line of the output file should contain the result of performing the mathematical operation for the corresponding element of the list that was passed to this function. You may use the split() function to split each string into it’s separate parts.
Part 3 : 20 pts Create a main function that will ask the user to input a file name. Pass that file name to the first function of this assignment. Pass the value that is returned from the first function into the second function. Don’t forget to call main at the end of your program
Notes: You should turn in only one file. The input file that I will use to test your program will contain a string that follows the format described in part two on each line of that file. You will not have to check that the input is valid.