Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

you are going to open a file in your program. the program is saved in a…

Question

you are going to open a file in your program. the program is saved in a folder, which has a subfolder called \textfiles.\ in the textfiles folder is a text file called \books.txt.\ which line of code will open books.txt? filein = open(\textfiles/books.txt\,
\) filein = open(\books.txt\,
\) filein.open(\textfiles/books.txt\,
\) filein.open(\books.txt\,
\)

Explanation:

Brief Explanations

In Python, the open() function is used to open files. When the file is in a sub - folder, the correct syntax includes the sub - folder name followed by the file name separated by a forward - slash (/). Also, the open() function is called directly, not as a method on an object (in the correct basic file - opening syntax). The mode "r" is for reading.

Answer:

fileIn = open("textFiles/books.txt","r")