File Handling in Python Class 12 MCQ

Share with others

File Handling in Python is a crucial topic in the Class 12 Computer Science CBSE curriculum. It focuses on how to work with text and binary files using Python’s built-in functions. This topic is important for both theory and practical exams.

File Handling in Python Class 12 MCQ

1. A text file stores information is __________ characters.
a. ASCII
b. Unicode
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

2. In text files, each line of text is terminated, with a special character known as ___________.
a. EOL 
b. EOF
c. EEF
d. All of the above

Show Answer ⟶
a. EOL

3. Which one of the following is correct for carriage-return and newline combination.
a. \r\n 
b. /r/n
c. \r/n
d. /r\n

Show Answer ⟶
a. \r\n

4. A _________ file is just a file that contains information in the same format in which the information is held in memory.
a. Text file
b. Binary file 
c. Word file
d. None of the above

Show Answer ⟶
b. Binary file

5. _________file format are faster and easier for a prgram to read and write than other file format.
a. Text file
b. Binary file 
c. Doc file
d. None of the above

Show Answer ⟶
b. Binary file

6. The command for opening a file in Python file handling is ____________.
a. open() 
b. update()
c. both a) and b)
d. None of the above

Show Answer ⟶
a. open()

7. The command for closing a file in Python file handling is ____________.
a. close() 
b. closing()
c. object()
d. None of the above

Show Answer ⟶
a. close()

8. _________ text file mode is used to read data from file.
a. ‘r’
b. ‘rb’
c. ‘r+’
d. None of the above

Show Answer ⟶
a. ‘r’

9. _________ text file mode is used to apped data in the file using file handling.
a. ‘w’
b. ‘ab’
c. ‘a’ 
d. None of the above

Show Answer ⟶
c. ‘a’

10. _________ binary file mode is used to append data in the file using file handling.
a. ‘ab’ 
b. ‘w’
c. ‘a’
d. None of the above

Show Answer ⟶
a. ‘ab’

11. Which of the following option is correct for ‘a+’ text file mode.
a. File is create if does not exit
b. If file exist, file’s existing data is retained; new data is appended
c. Both reading and writing operation can take palce.
d. All of the above 

Show Answer ⟶
d. All of the above

12. ___________ function is used to read the data from the file.
a. read()
b. readline()
c. readlines()
d. All of the above 

Show Answer ⟶
d. All of the above

13. Which function is used to write data onto a file.
a. write()
b. writelines()
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

14. Python holds everything to write in the file in buffer. if you want to force python to write the contents of buffer onto storage, you can use ________ function.
a. flush() 
b. push()
c. clear()
d. None of the above

Show Answer ⟶
a. flush()

15. Which function is used to remove whitespace after reading a file in file handling.
a. write()
b. read()
c. strip() 
d. None of the above

Show Answer ⟶
c. strip()

16. _________ removes the given character from trailing end or from the right end.
a. strip()
b. rstrip() 
c. lstrip()
d. None of the above

Show Answer ⟶
b. rstrip()

17. A text file can be opened in ________ file modes.
a. ‘r’ and ‘w’
b. ‘a’ and ‘r+’
c. ‘w+’ and ‘a+’
d. All of the above 

Show Answer ⟶
d. All of the above

18. A binary file can be opend in ________ file mode.
a. ‘rb’ and ‘wb’
b. ‘ab’ and ‘r+b’
c. (‘rb+’), ‘w+b'(wb+’), ‘a+b'(‘ab+’)
d. All of the above 

Show Answer ⟶
d. All of the above

19. ________ are the standard streams in file handling.
a. stdin (standard input)
b. stdout (standard output)
c. stderr (standard error)
d. All of the above 

Show Answer ⟶
d. All of the above

20. The input and output devices are implemented as file, also called __________.
a. Standard streams 
b. Standard Binary
c. Standar Text
d. None of the above

Show Answer ⟶
a. Standard streams

21. In python directory denonted as a dot(.) while its parent directory is denoted with ________.
a. Three dots(…)
b. Two dots(..) 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Two dots(..)

Computer Science Class 12 MCQs

Disclaimer: We have taken an effort to provide you with the accurate handout of “File Handling in Python Class 12 MCQ“. If you feel that there is any error or mistake, please contact me at anuraganand2017@gmail.com. The above CBSE study material present on our websites is for education purpose, not our copyrights. All the above content and Screenshot are taken from Computer Science Class 12 NCERT Textbook, CBSE Sample Paper, CBSE Old Sample Paper, CBSE Board Paper and CBSE Support Material which is present in CBSEACADEMIC website, NCERT websiteThis Textbook and Support Material are legally copyright by Central Board of Secondary Education. We are only providing a medium and helping the students to improve the performances in the examination. 

Images and content shown above are the property of individual organizations and are used here for reference purposes only.

For more information, refer to the official CBSE textbooks available at cbseacademic.nic.in


Share with others

Leave a Comment