output of following code fragment?
out = open("output.txt", "w")
out.write("Hello, world! \n")
out.write("How are you?")
How are you?'
The output will be:
The first line of the code is opening the file in write mode;
the next two lines write text to the file. The last line opens the file and from that reference reads the file-content.
Function file() does the same as that of open().
Thus file("output.txt") will give the reference to open file, on which read() is applied.