Rajan Kumar of class 12 is writing a program to create a CSV file “user.csv” which will
contain user name and password for some entries. He has written the following code. As a
programmer, help him to successfully execute the given task.
import _____________
def addCsvFile(UserName,PassWord): # to write / add data into the CSV file
f=open(' user.csv','________')
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv._________(newFile)
for row in newFileReader:
print (row[0],row[1])
newFile.______________
#main program
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile()
(a) Name the module he should import in Line 1. 1 mark
(b) In which mode, Rajan should open the file to add data into the file (Line 4) 1 mark
(c) Fill in the blank in Line 3 to read the data from a csv file. 1 mark
(d) Fill in the blank in Line 4 to close the file. 1 mark
(e) Write the output he will obtain while executing Line 5. 1 mark
Answers
Answered by
61
Explanation:
import CSV #line 1
"w" mode
reader()
writerows()
Arjun. 123@456
Arunima aru@nima
Frieda. myname@FRD
follow me mark me as brainly
Answered by
16
Explanation:
this is the answer....hope it will help you.
Attachments:
Similar questions