Q141. Ananya was writing a program of reading data from csv file named "data.csv". She writes the incomplete code. As a friend of Ananya help her to complete the code.
________ csv #Statement1
f=open("data.csv", '_______') #Statement2
d=csv.___________(f) #Statement3
for __________ in d: #Statement4
print(row)
Identify the suitable option for Statement 1
Q142. Identify the correct option for Statement2 (Refer Q 141)
Q143. Identify the correct option for Statement3 (Refer Q 141)
Q144. Identify the correct option for Statement4 (Refer Q 141)
Q145. Parth is writing a program to add/insert records in file “data.csv”. He has written the following code. As a programmer, help him to execute it successfully.
import csv
field = ["Roll no" , "Name" , "Class"]
f = open("_________" , 'w') #Statement1
d=__________.writer(f) #Statement2
d.writerow(field)
ch='y'
while ch=='y' or ch=='Y':
rn=int(input("Enter Roll number: "))
nm = input("Enter name: ")
cls = input("Enter Class: ")
rec=[_________] #Statement3
d.writerow(rec)
ch=input("Enter more record??(Y/N)")
f.close()
Identify the correct statement for Statement 1
Q146. Identify the correct statement for Statement 2. (Refer Q. 145)
Q147. Identify the correct statement for Statement 3. (Refer Q. 145)
Q148. Chinki is writing a program to copy the data from “data.csv” to “temp.csv”. However she is getting some error in executing the following program due to some missing commands. Help her to execute it successfully.
import csv
f=open("data.csv","r")
f1=open("temp.csv",'__________') #Statement 1
d=csv._________(f) #Statement 2
d1=csv.writer(f1)
for i in d:
___________.writerow(i) #Statement3
f.close( )
f1.close( )
Identify the correct statement for Statement 1.
Q149. Identify the correct statement for Statement 2.(Refer Q148.)
Q150. Identify the correct statement for Statement 3.(Refer Q148.)