Python MCQs on File Handling: SET 1

Python MCQs on File Handling

In this section, we are going to introduce you to the most frequently asked Python MCQs on File Handling. These Python MCQs on File Handling will be going to help you in Interviews and Exams.

 

Q1. Which statement will read 5 characters from a file(file object ‘f’)?

a. f.read()

b. f.read(5)

c. f.reads(5)

d. None of the above

Check Answer

Answer: c. f.reads(5)

Q2. Which function open file in python?
a. open( )

b. new( )

c. Open( )

d. None of the above

Check Answer

Answer: a. open( )

Q3. Processing of Text file is faster than binary files.(T/F)
a. True

b. False

Check Answer

Answer: b. False

Q4. Which mode create new file if the file does not exist?
a. write mode

b. append mode

c. Both of the above

d. None of the above

Check Answer

Answer: C. Both of the above

Q5. Which statement will return one line from a file (file object is ‘f’)?
a. f.readline( )

b. f.readlines( )

c. f.read( )

d. f.line( )

Check Answer

Answer: a. f.readline( )

Q6. readlines() method return _________
a. String

b. List

c. Dictionary

d. Tuple

Check Answer

Answer: b. List

Q7. EOF stands for _________________
a. End of File

b. End off File

c. End on File

d. End or File

Check Answer

Answer: a. End of File

Q8. Which function is used to read data from Text File?
a. read( )

b. writelines( )

c. pickle( )

d. dump( )

Check Answer

Answer: a. read( )

Q9. Which of the following will read entire content of file(file object ‘f’)?
a. f.reads( )

b. f.read( )

c. f.read(all)

d. f.read( * )

Check Answer

Answer: b. f.read( )

Q10. Which symbol is used for append mode?
a. ap

b. a

c. w

d. app

Check Answer

Answer: b. a

We Will update the Questions Soon

Page  1  2  3  4  5  6

Python Interview Questions (MCQs)

We have divided these Python Questions and Answers into various parts based on the topics. Open the Topic of your choice and Practice these MCQs.

Python MCQs on Variables and Operators Python MCQs on Precedence and Associativity
Python MCQs on Data Type Python MCQs on Boolean
Python MCQs on Bitwise Operators Python MCQs on Formatting and Advance Formatting
Python MCQs on Decorators Python MCQs on While and For Loops
Python MCQs on List Python MCQs on List Comprehension
Python MCQs on String Python MCQs on Tuple
Python MCQs on SET Python MCQs on Dictionary
Python MCQs on Functions Python MCQs on Argument Parsing
Python MCQs on Global and Local Variables Python MCQs on Recursion
Python MCQs on Mapping Functions Python MCQs on Modules
Python MCQs on Regular Expressions Python MCQs on Files
Python MCQs on Overloading Python MCQs on Classes and Objects
Python MCQs on Inheritance Python MCQs on Polymorphism and Encapsulation
Python MCQs on Exception Handling

Leave a Comment