Python File Handling MCQs with Answers Set 02

Objective Questions and Answers: File Handling

Explore reliable objective questions for File Handling tailored for learners. Utilizing these multiple-choice formats ensures thorough preparation and strengthens problem-solving speed for upcoming school assessments.

Download File Handling MCQs with Answers

Navigate directly to the 50 objective questions for File Handling using the digital viewer below. Each practice set includes verified answer keys, allowing students to instantly cross-check their work and identify areas requiring further revision.

Question. What is the use of seek() method in files?
(a) sets the file’s current position at the offset
(b) sets the file’s previous position at the offset
(c) sets the file’s current position within the file
(d) none of the mentioned
Answer: sets the file’s current position at the offset

Question. How do you get the name of a file from a file object (f)?
(a) \( f.name \)
(b) \( f.file(name) \)
(c) \( self.\_\_name\_\_(f) \)
(d) \( f.\_\_name\_\_() \)
Answer: f.name

Question. What is the use of “w” in file handling?
(a) Read
(b) Write
(c) Append
(d) None of the mentioned

Question. What is the correct syntax to remove() a file?
(a) \( remove(file\_name) \)
(b) \( remove(new\_file\_name, current\_file\_name,) \)
(c) \( remove(() , file\_name)) \)
(d) none of the mentioned
Answer: remove(file_name)

Question. To read two characters from a file object f, we use ____________
(a) \( f.read(2) \)
(b) \( f.read() \)
(c) \( f.readline() \)
(d) \( f.readlines() \)
Answer: f.read(2)

Question. What is the correct syntax of rename() a file?
(a) \( rename(current\_file\_name, new\_file\_name) \)
(b) \( rename(new\_file\_name, current\_file\_name,) \)
(c) \( rename(()(current\_file\_name, new\_file\_name)) \)
(d) none of the mentioned

Question. Which of the following statements are true?
(a) When you open a file for reading an error occurs, if the file does not exist
(b) When you open a file for writing a new file is created, if the file does not exist
(c) When you open a file for writing, the existing file is overwritten with the new file, if the file exists,
(d) All of the mentioned

Question. Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
(a) \( raw\_input \) & Input
(b) Input & Scan
(c) Scan & Scanner
(d) Scanner
Answer: raw_input & Input

Question. What happens if no arguments are passed to the seek function?
(a) file position is set to the start of file
(b) file position is set to the end of file
(c) file position remains unchanged
(d) error
Answer: error

Question. To read the next line of the file from a file object f, we use ___________
(a) \( f.read(2) \)
(b) \( f.read() \)
(c) \( f.readline() \)
(d) \( f.readlines() \)
Answer: f.readline()

Question. What is the use of truncate() method in file?
(a) truncates the file size
(b) deletes the content of the file
(c) deletes the file size
(d) none of the mentioned
Answer: truncates the file size

Question. Is it possible to create a text file in Python?
(a) Yes
(b) No
(c) Machine dependent
(d) All of the mentioned
Answer: Yes

Question. Which of the following are the modes of both writing and reading in binary format in file?
(a) \( wb+ \)
(b) \( w \)
(c) \( wb \)
(d) \( w+ \)
Answer: wb+

Question. What is the difference between r+ and w+ modes?
(a) No difference
(b) In case of \( r+ \) the pointer is initially placed at the beginning of the file and the pointer is at the end for \( w+ \)
(c) In case of \( w+ \) the pointer is initially placed at the beginning of the file and the pointer is at the end for \( r+ \)
(d) Depends on the operating system
Answer: In case of r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+

Question. To open a file c:\text.txt for appending data, we use ___________
(a) \( outfile = open(“c:\\test.txt”, “a”) \)
(b) \( outfile = open(“c:\\test.txt”, “rw”) \)
(c) \( outfile = open(file = “c:\\test.txt”, “w”) \)
(d) \( outfile = open(file = “c:\\test.txt”, “w”) \)
Answer: outfile = open(“c:\\test.txt”, “a”)

Question. Correct syntax of file.readlines() is?
(a) \( fileObject.readlines( sizehint ); \)
(b) \( fileObject.readlines(); \)
(c) \( fileObject.readlines(sequence) \)
(d) none of the mentioned

Question. Command to delete a file.
(a) \( del(fp) \)
(b) \( fp.delete() \)
(c) \( os.remove(‘file’) \)
(d) \( os.delete(‘file’) \)

Question. Which function is used to write all the characters?
(a) \( write() \)
(b) \( writecharacters() \)
(c) \( writeall() \)
(d) \( writechar() \)
Answer: write()

Question. What is the correct syntax of open() function?
(a) \( file = open(file\_name [, access\_mode][, buffering]) \)
(b) \( file object = open(file\_name [, access\_mode][, buffering]) \)
(c) \( file object = open(file\_name) \)
(d) none of the mentioned
Answer: file object = open(file_name [, access_mode][, buffering])

Question. Which of the following is not a valid attribute of a file object (f)?
(a) \( f.name \)
(b) \( f.closed \)
(c) \( f.mode \)
(d) \( f.size \)
Answer: f.size

Question. Which one of the following is not attributes of file?
(a) closed
(b) softspace
(c) rename
(d) mode

Question. Which function is used to read single line from file?
(a) \( readline() \)
(b) \( readlines() \)
(c) \( readstatement() \)
(d) \( readfullline() \)

Question. Which of the following mode will refer to binary data?
(a) r
(b) w
(c) +
(d) b

Question. To open a file c:\text.txt for reading, we use _____________
(a) \( f = open(“c:\\test.txt”, “r”) \)
(b) \( f = open(“c:\\test.txt”, “r”) \)
(c) \( f = open(file = “c:\\test.txt”, “r”) \)
(d) \( f = open(file = “c:\\test.txt”, “r”) \)
Answer: f = open(“c:\\test.txt”, “r”)

Question. Change the file position to an offset value from the starting position.
(a) \( fp.seek(offset, 0) \)
(b) \( fp.seek(offset, 1) \)
(c) \( fp.seek(offset, 2) \)
(d) none of the mentioned
Answer: fp.seek(offset, 0)

Question. What is the use of tell() method in python?
(a) Inform you the current position within the file
(b) Inform you the end position within the file
(c) Inform you the file is opened or not
(d) None of the mentioned
Answer: Inform you the current position within the file

Question. How do you close a file object (fp)?
(a) \( close(fp) \)
(b) \( fclose(fp) \)
(c) \( fp.close() \)
(d) \( fp.\_\_close\_\_ \() \)
Answer: fp.close()

Question. Correct syntax of file.writelines() is?
(a) \( file.writelines(sequence) \)
(b) \( fileObject.writelines() \)
(c) \( fileObject.writelines(sequence) \)
(d) none of the mentioned

Question. In file handling, what does this terms means “r, a”?
(a) read, append
(b) append, read
(c) write, append
(d) none of the mentioned
Answer: read, append

Question. To open a file c:\text.txt for writing, we use ____________
(a) \( outfile = open(“c:\\test.txt”, “w”) \)
(b) \( outfile = open(“c:\\test.txt”, “w”) \)
(c) \( outfile = open(file = “c:\\test.txt”, “w”) \)
(d) \( outfile = open(file = “c:\\test.txt”, “w”) \)
Answer: outfile = open(“c:\\test.txt”, “w”)

Question. Which function is used to write a list of string in a file?
(a) \( writeline() \)
(b) \( writelines() \)
(c) \( writestatement() \)
(d) \( writefullline() \)
Answer: writeline()

Question. Which function is used to read all the characters?
(a) \( read() \)
(b) \( readcharacters() \)
(c) \( readall() \)
(d) \( readchar() \)

Question. Which of the following is not a valid mode to open a file?
(a) ab
(b) rw
(c) r+
(d) w+
Answer: rw

Question. The readlines() method returns ____________
(a) str
(b) a list of lines
(c) a list of single characters
(d) a list of integers

Question. Which function is used to close a file in Python?
(a) \( close() \)
(b) \( stop() \)
(c) \( end() \)
(d) \( closefile() \)
Answer: close()

Question. How do you get the current position within the file?
(a) \( f.seek() \)
(b) \( f.tell() \)
(c) \( f.loc \)
(d) \( f.pos \)
Answer: f.tell()

Question. To read the remaining lines of the file from a file object f, we use __________
(a) \( f.read(2) \)
(b) \( f.read() \)
(c) \( f.readline() \)
(d) \( f.readlines() \)
Answer: f.readlines()

Question. To read the entire remaining contents of the file as a string from a file object f, we use ___________
(a) \( f.read(2) \)
(b) \( f.read() \)
(c) \( f.readline() \)
(d) \( f.readlines() \)
Answer: f.read()

Question. Which of the following is not a correct statement for binary files?
(a) Easy for carrying data into buffer
(b) Much faster than other file systems
(c) Characters translation is not required
(d) Every line ends with new line character \( ‘\backslash n’ \)
Answer: d

Question. Which of the following file mode open a file for reading and writing both in the binary file?
(a) r
(b) rb
(c) rb+
(d) rwb
Answer: c

Question. Which of the following file mode opens a file for reading and writing both as well as overwrite the existing file if the file exists otherwise creates a new file?
(a) w
(b) wb+
(c) wb
(d) rwb
Answer: b

Question. Which of the following file mode opens a file for append or read a binary file and moves the files pointer at the end of the file if the file already exist otherwise create a new file?
(a) a
(b) ab
(c) ab+
(d) a+
Answer: c

Question. Ms. Suman is working on a binary file and wants to write data from a list to a binary file. Consider list object as \( l1 \), binary file suman_list.dat, and file object as f. Which of the following can be the correct statement for her?
(a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
(b) f = open(‘sum_list’,’rb’); l1=pickle.dump(f)
(c) f = open(‘sum_list’,’wb’); pickle.load(l1,f)
(d) f = open(‘sum_list’,’rb’); l1=pickle.load(f)
Answer: a

Question. Which option will be correct for reading file for suman from q-5?
Answer: f = open(‘sum_list’,’rb’); l1=pickle.load(f)

Question. In which of the file mode existing data will be intact in binary file?
(a) ab
(b) a
(c) w
(d) wb
Answer: a

Question. Which one of the following is correct statement?
(a) import – pickle
(b) pickle import
(c) import pickle
(d) All of the above
Answer: c

Question. Every file has its own identity associated with it. Which is known as –
(a) icon
(b) extension
(c) format
(d) file type
Answer: b

Question. Which of the following is not a known file type?
(a) .pdf
(b) jpg
(c) mp3
(d) txp
Answer: d

Question. In f=open(“data.txt”, “r”), r refers to __________.
(a) File handle
(b) File object
(c) File Mode
(d) Buffer
Answer: c

Question. EOL stands for
(a) End Of Line
(b) End Of List
(c) End of Lines
(d) End Of Location
Answer: a

Question. Which of the following file types allows to store large data files in the computer memory?
(a) Text Files
(b) Binary Files
(c) CSV Files
(d) None of these
Answer: b

Question. Which of the following file types can be opened with notepad as well as ms excel?
(a) Text Files
(b) Binary Files
(c) CSV Files
(d) None of these
Answer: c

Question. Which of the following is nor a proper file access mode?
(a) close
(b) read
(c) write
(d) append
Answer: a

Question. To read 4th line from text file, which of the following statement is true?
(a) dt = f.readlines();print(dt[3])
(b) dt=f.read(4) ;print(dt[3])
(c) dt=f.readline(4);print(dt[3])
(d) All of these
Answer: a

Question. Which of the following function flushes the files implicitly?
(a) flush()
(b) close()
(c) open()
(d) fflush()
Answer: b

Question. Which of the following functions flushes the data before closing the file?
(a) flush()
(b) close()
(c) open()
(d) fflush()
Answer: a

Multiple Choice Questions (MCQs) for File Handling

Chapter MCQs with Answers for

Review structured objective questions for File Handling. Built according to official NCERT guidelines, these MCQ sets support daily revision and core concept reinforcement.

Expert Practice Material for

Built using the official NCERT book for , these objective sets provide reliable academic guidance. Pair your practice with our recommended NCERT solutions to master optimal problem-solving approaches.

Complete Your Chapter Revision

Explore our broader library of printable assignments, chapter notes, and mock tests designed to support continuous revision and secure higher marks in NCERT assessments.

FAQs

Where can I access latest Python File Handling MCQs with Answers Set 02?

You can get most exhaustive Python File Handling MCQs with Answers Set 02 for free on StudiesToday.com. These MCQs for are updated for the 2026-27 academic session as per examination standards.

Are Assertion-Reasoning and Case-Study MCQs included in the [current-page:node:field_subject] [current-page:node:field_class] material?

Yes, our Python File Handling MCQs with Answers Set 02 include the latest type of questions, such as Assertion-Reasoning and Case-based MCQs. 50% of the paper is now competency-based.

How do practicing [current-page:node:field_subject] MCQs help in scoring full marks in [current-page:node:field_class] exams?

By solving our Python File Handling MCQs with Answers Set 02, students can improve their accuracy and speed which is important as objective questions provide a chance to secure 100% marks in the .

Do you provide answers and explanations for Python File Handling MCQs with Answers Set 02?

Yes, MCQs for have answer key and brief explanations to help students understand logic behind the correct option as its important for 2026 competency-focused exams.

Can I practice these [current-page:node:field_subject] [current-page:node:field_class] MCQs online?

Yes, you can also access online interactive tests for Python File Handling MCQs with Answers Set 02 on StudiesToday.com as they provide instant answers and score to help you track your progress in .