data collections objects from the filedef readstudents(filename)infile open(filename' 'students [for line in infilestudents append(makestudent(line)infile close(return students this function first opens the file for reading and then reads line by lineappending student object to the students list for each line of the file notice that am borrowing the makestudent function from the gpa programit creates student object from line of the file we will have to be sure to import this function (along with the student classat the top of our program while we're thinking about fileslet' also write function that can write the list of students back out to file remembereach line of the file should contain three pieces of information (namecredit hoursand quality pointsseparated by tabs the code to do this is straightforward def writestudents(studentsfilename)students is list of student objects outfile open(filename' 'for in studentsprint("{ }\ { }\ { }format( getname() gethours() getqpoints())file=outfileoutfile close(notice that used the string formatting method to generate the appropriate line of outputthe \ represents tab character using the functions readstudents and writestudentswe can easily convert our data file into list of students and then write it back out to file all we have to do now is figure how to sort the records by gpa in the statistics programwe used the sort method to sort list of numbers what happens if we try to sort list that contains something other than numbersin this casewe want to sort list of student objects let' try that out and see what happens lst gpasort readstudents("students dat"lst [lst sort(traceback (most recent call last)file ""line in typeerrorunorderable typesstudent(student(