appendix python review the function takes two string arguments the first is the name of the file and the second indicates the mode in which the file is to be opened the modes are' ' -open the file for reading -open the file for writing new in python xpython now includes multiple classes for working with files the file(constructor no longer exists and cannot be used to open file insteadyou must use the open(functionwhich creates and returns an appropriate file object based on the supplied arguments if the file can be openedthe function creates file object and returns reference to that newly created object this object is then used to access the file file opened for reading must exist and be accessible to the user running the program if file is opened for writing and it does not exista new file is createdbut if the file existsit will be erased and new file created if the file cannot be openedan error is generated when you are finished using the fileit should be closed by closing the filethe system will flush the buffers and unlink the external file from the internal python object file cannot be used after it has been closed to reuse the fileyou must first reopen it python files are closed by calling the close(method defined for file objectsinfile close(outfile close( writing to files python provides several methods for outputting data to text file the easiest way to write text to text file is with the write(method defined for file objectsoutfile write"student report\noutfile write"- "\nthe write(method writes the given string to the output file represented by the given file object to output other value typesyou must first convert them to strings formatted output can also be written to file using the string format operatoroutfile write"% % \ (idnumavggradenote that the write(method does not add linefeed or newline character after the string is written to the file this must be done explicitly by including newline character (\nas part of the output string