Class 12 : File Handling Set 2

In which of the following file modes existing data of a file will not be lost?

a) ab+
b) wb+
c) w+
d) wb


Which of the following command is used to open a file “c:\pat.txt” for writing as well as reading in binary format?

a) fout=open(“c:\pat.txt”,”w”)
b) fout=open(“c:\\pat.txt”,”wb”)
c) fout=open(“c:\pat.txt”,”w+”)
d) fout=open(“c:\pat.txt”,”wb+”)


…………. returns a writer object to write the data into a csv file.

a) writer()
c) writer.csv()
d) csv.writerobject()


…………. loads the data from a csv file into an iterable after parsing delimited data.

a) reader.csv()
b) csvreader()
c) csv.reader()
d) readerobject(csv)


To open a file c:\res.txt for reading which of the statements are correct?

a) file=open(“c:\res.txt”,”r”)
b) file=open(“c:\\res.txt”,”r”)
c) file=open(“c:\res.txt”)
d) file=open(“c:\\res.txt”)