QUESTION IMAGE
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\,
\)
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.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
B. fileIn = open("dataFiles/games.txt","r")