Computer Science, asked by Shazuchamp7278, 2 months ago

Differentiate between the following (i) f=open(‘diary.txt’,’r’) (ii) f=open(‘diary.txt’,’w’)

Answers

Answered by Anonymous
2

Answer :-

The first one is to open the file named diary.txt in the reading mode and storing it in a variable named 'f'. Here we have specified the reading mode by 'r'. It is just used to open the file for reading and is the default mode, i.e. if you don't specify the mode, your file will be directly opened in reading mode.

The second one is to open the file named diary.txt in writing mode and storing it in a variable named 'f'. We have specified the mode as 'writing' by 'w'. If the file named diary.txt is not present, the command will create a file named diary.txt and will open the file in writing mode.

That's the difference between the two !!!

Similar questions