File Handling in Python · Class 12 · CBSE · Science Computer Science

What type of data is returned when a file is opened using open("data.bin", "rb") and its contents are read?

Practice question from File Handling in Python (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

medium · MCQ · Q-61CA91

What type of data is returned when a file is opened using open("data.bin", "rb") and its contents are read?

  1. A.A string
  2. B.A bytes objectCorrect answer
  3. C.A list of characters
  4. D.A dictionary

Solution

The rb mode opens a file for reading in binary mode. Reading from a binary file produces a bytes object rather than a string.

More from File Handling in Python

All of File Handling in Python

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed