Test Index
File Handling in Python
© examsnet.com
Question : 1 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 ?[CBSE 2026 Set 4]
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
Go to Question: