1.

To open a file c:\scores.txt for writing, we use ____________(a) outfile = open(“c:\scores.txt”, “w”)(b) outfile = open(“c:\\scores.txt”, “w”)(c) outfile = open(file = “c:\scores.txt”, “w”)(d) outfile = open(file = “c:\\scores.txt”, “w”)The question was posed to me in exam.This intriguing question originated from Files topic in section Regular Expressions and Files of Python

Answer»

The correct choice is (B) outfile = open(“c:\\scores.txt”, “W”)

The best I can explain: w is used to indicate that file is to be WRITTEN to.



Discussion

No Comment Found

Related InterviewSolutions