Site icon CBSECS

12-computer-science-python-binary-files-mcq

๐Ÿง  Python Binary Files โ€“ 20 MCQs

  1. What is the file mode to open a binary file for reading?

  1. Which module is used to work with binary files in Python?

  1. What does pickle.dump() do?

  1. What does pickle.load() return?

  1. Which of the following is a binary file extension?

  1. What is the default protocol used by pickle.dump()?

  1. Which mode appends data to a binary file?

  1. What is the data type returned by f.read() in binary mode?

  1. Which method is used to serialize Python objects?

  1. What happens if you try to unpickle a corrupted file?

  1. Which of the following is NOT a valid binary mode?

  1. What does protocol=0 in pickle.dump() signify?

  1. Which function is used to open a file in Python?

  1. What does 'wb' mode do?

  1. Which method reads all lines from a file?

  1. What is the purpose of seek() method?

  1. Which method is used to write multiple strings to a file?

  1. What does fix_imports=True do in pickle.dump()?

  1. Which file mode allows both reading and writing without erasing data?

  1. What is the output type of pickle.load()?

ย 

Python Binary Files โ€“ Class 12 MCQs

  1. What is the file mode to open a binary file for reading?
    Show AnswerB) โ€˜rbโ€™
  2. Which module is used to work with binary files in Python?
    Show AnswerB) pickle
  3. What does pickle.dump() do?
    Show AnswerB) Writes a Python object to a binary file
  4. What does pickle.load() return?
    Show AnswerC) The original Python object
  5. Which of the following is a binary file extension?
    Show AnswerC) .jpg
  6. What is the default protocol used by pickle.dump()?
    Show AnswerD) Highest available protocol
  7. Which mode appends data to a binary file?
    Show AnswerB) โ€˜abโ€™
  8. What is the data type returned by f.read() in binary mode?
    Show AnswerC) Bytes
  9. Which method is used to serialize Python objects?
    Show AnswerB) dump()
  10. What happens if you try to unpickle a corrupted file?
    Show AnswerC) Raises UnpicklingError
  11. Which of the following is NOT a valid binary mode?
    Show AnswerD) โ€˜rbbโ€™
  12. What does protocol=0 in pickle.dump() signify?
    Show AnswerC) Oldest protocol
  13. Which function is used to open a file in Python?
    Show AnswerC) open()
  14. What does โ€˜wbโ€™ mode do?
    Show AnswerB) Opens file for writing in binary
  15. Which method reads all lines from a file?
    Show AnswerC) readlines()
  16. What is the purpose of seek() method?
    Show AnswerC) To move the file pointer
  17. Which method is used to write multiple strings to a file?
    Show AnswerB) writelines()
  18. What does fix_imports=True do in pickle.dump()?
    Show AnswerB) Ensures compatibility between Python versions
  19. Which file mode allows both reading and writing without erasing data?
    Show AnswerB) โ€˜r+โ€™
  20. What is the output type of pickle.load()?
    Show AnswerC) Original Python object
Exit mobile version