A text file student.txt is stored in the storage device. Identify the correct option out of the following options to open the file in read mode.
i. myfile = open('student.txt','rb')
ii. myfile = open('student.txt','w')
iii. myfile = open('student.txt','r')
iv. myfile = open('student.txt')
a. only i
b. both i and iv
c. both iii and iv
d. both i and iii
Answers & Comments
Answer:
c. both iii and iv
Explanation:
Verified answer
[tex]{\huge{\underline{\underline{\boxed{\orange{\mathscr{ Answer }}}}}}}[/tex]
The correct option to open the file in read mode is:
c. both iii and iv
So, the code would be:
myfile = open('student.txt', 'r')
Option iv (`open('student.txt')`) is equivalent to opening the file in read mode. Option iii (`open('student.txt', 'r')`) explicitly specifies opening the file in read mode.