Q. Read the code given below and answer the question:-
fh = open("main.txt", "W")
fh.write("Bye")
fh.close()
If the file contains “GOOD” before execution, what will be the contents of the file after execution of this code?
Answer :-
The file would now contain "Bye" only, because when an existing file is opened in write mode ("w"), it truncates the existing data the file.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )