Q. What is the output of the following code fragment? Explain.
fout = file ("output.txt", 'w')
fout.write("Hello world! \n")
fout.write("How are you?")
fout.close()
file("output.txt").read()
Output :-
fout = file ("output.txt", 'w')
NameError: name 'file' is not defined
It will give above Error.
So, I think Correct program should be :-
fout = open ("output.txt", 'w') fout.write("Hello world! \n") fout.write("How are you?") fout.close() file = open("output.txt").read() print(file)
Output :-
Hello world!
How are you?
>>>
Good
ReplyDeleteThank you : )
DeleteWhere is the answer?
ReplyDeleteI have updated it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )