use python write a function max num in file filename that returns the largest intege 5155041
Use python. Write a function max_num_in_file(filename) that returns the largest integer found in the file (as an integer). The file contains only numbers and has one number per line. The file will contain at least one line. For example if the file called test.txt contains the following code then a call to max_num_in_file would return the value 5. 1 2 3 4 5
U AWNA det max_num_in_Tile Tilename): returns the largest integer found in the file (as an integer).” data = open(filename) # Default is open for reading empty = [ for num in data: # Processsed file by line empty.append(num) results = max(empty) res = (str(i) for i in results] ans = int(“”.join(res)) data.close() return ans Test Expected Got answer = max_num_in_file('max_num_in_file_test_01.txt') 5 print(answer) 100 answer = max_num_in_file( 'max_num_in_file_test_02.txt') 100 print(answer) answer = max_num_in_file( 'max_num_in_file_test_03.txt') 3000 print(answer) “'”Note: the test data for this test is: 100 76 * 10 200 3000 22 76