Class 1 Class 2 Class 3 Class 4 Class 5 Class 6 Class 7 Class 8

File Handling in Python Class 12 MCQ

тЖР Back to Class 12 CS Main Page

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(..)

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

тЖР Back to Class 12 CS Main Page

Leave a Comment