Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

you are going to open a file in your program to use what is already in …

Question

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

Explanation:

Brief Explanations

In Python, to open a file that is in a sub - folder, you need to specify the path. The correct syntax to open a file in read mode ("r") is open("path/to/file", "r"). Here the file games.txt is in the dataFiles sub - folder, so the path should be included. Also, open is a built - in function, not a method of an object like fileIn.

Answer:

B. fileIn = open("dataFiles/games.txt","r")