End of File Handling (3 marks)
Consider the following code used to read a file until the end: myFileHandler = open(“myFile.txt”) while NOT myFileHandler.endOfFile() print(myFileHandler.readLine()) endwhile myFileHandler.close() (a) Explain what the endOfFile() method does in this context. (1 mark) (b) What does readLine() do in this loop? (1 mark) (c) Why is it important to close the file after all operations […]
End of File Handling (3 marks) Read More »