1) What is the primary purpose of file handling in Python? a) To create new files b) To manipulate text data c) To organize folders d) To interact with external files and data 2) What is the purpose of the with statement (context manager) when working with files in Python? a) It defines a new function b) It is used for commenting code c) It ensures that the file is properly closed after use d) It allows you to write to a file 3) Which method is used to read a single line from a text file in Python? a) read() b) readlines() c) readline() d) readline(2) 4) What exception might occur when you attempt to open a file that doesn't exist in Python? a) FileNotFoundError b) ValueError c) PermissionError d) TypeError 5) the file object. What is the default value of reference_point? a) 0 b) 1 c) 2 d) 3 6) Which of the following statement is incorrect in the context of binary files? a) Information is stored in the same format as in memory b) No character translation takes place c) Every line ends with a new line character d) pickle module is used for reading and writing 7) of the following option can be used to read all the remaining lines? a) myfile.read() b) myfile.read(n) c) myfile.readline() d) myfile.readlines() 8) Which of the following character acts as default delimiter in a csv file? a) : b) ; c) , d) - 9) Which of the following functions changes the position of file pointer a) flush() b) tell() c) seek() d) offset() 10) The correct syntax of seek() is: a) file_object.seek(offset [, reference_point]) b) seek(offset [, reference_point]) c) seek(offset, file_object) d) seek.file_object(offset)

File Handling in Python

Leaderboard

Visual style

Options

Switch template

Continue editing: ?