Advertisements
Advertisements
प्रश्न
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?
विकल्प
a
rb
r+
rb+
MCQ
Advertisements
उत्तर
rb
Explanation:
- File Type: The extension
.datUsually indicates a binary file. - Read-Only Mode: In Python, the character 'r' is used for reading. Adding ‘b’ specifies that the file should be opened in binary mode.
- Why others are wrong:
- ‘a’ is for appending data.
- ‘r+’ allows both reading and writing.
- ‘rb+’ allows reading and writing in binary format.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
