Which of the following option is not correct?
a. if we try to read a text file that does not exist, an error occurs.
b. if we try to read a text file that does not exist, the file gets created.
c. if we try to write on a text file that does not exist, no error occurs.
d. if we try to write on a text file that does not exist, the file gets
Created.
Answers & Comments
Verified answer
[tex]{\huge{\underline{\underline{\boxed{\pink{\mathscr{ Answer }}}}}}}[/tex]
The option that is not correct is:
b. if we try to read a text file that does not exist, the file gets created.
When you try to read a text file that does not exist, it typically results in an error (such as a "FileNotFoundError" in Python) because there is no file to read. Reading a non-existent file does not create the file.
Option b is incorrect because it suggests that attempting to read a non-existent file creates the file, which is not the case.
Answer:
The option that is not correct is:
b. if we try to read a text file that does not exist, the file gets created.
When you try to read a text file that does not exist, it typically results in an error (such as a "FileNotFoundError" in Python) because there is no file to read. Reading a non-existent file does not create the file.
All the other options are correct:
a. if we try to read a text file that does not exist, an error occurs.
c. if we try to write on a text file that does not exist, no error occurs.
d. if we try to write on a text file that does not exist, the file gets created (if you are opening the file in write mode, it will create a new file if it doesn't exist).
Explanation: