Test Index

CBSE Class 12 Computer Science 2026 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 10 of 37
Marks: +1, -0
Consider the statement given below :
f1 = open("pqr.dat","________")
Which of the following is the correct file mode to open the file in read only mode ?
Solution:  
Concept:
'pqr.dat' is a binary file. File modes:
'a' : append (write only, at the end)
'rb' : read only, binary
'r+' : read and write (text)
'rb+' : read and write (binary)
Explanation:
Only 'rb' opens the file for reading alone. The '+' in 'r+' and 'rb+' adds writing, and 'a' is for writing.
Answer:
Option B (rb)
© examsnet.com
Advertisements
Go to Question: