CSV file read, write and search PYQ part 1
PYQ PRACTICE SCOPE: CSV file read, write and search.
Concept ID: U1_CSV_OPS.
Use only previous-year questions whose concept_ids include U1_CSV_OPS.
Key things we'll cover
CSV file read, write and search
PYQ references used by both prompts10 included0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included
ID 6489 · 2021 · 1 mark(s)
Which of the following character acts as default delimiter in a csv file?
a) (colon) :
b) (hyphen) -
c) (comma) ,
d) (vertical line) |
File Handling → CSV file read write and search
Included
ID 6491 · 2021 · 1 mark(s)
What is the correct expansion of CSV files?
a) Comma Separable Values
b) Comma Separated Values
c) Comma Split Values
d) Comma Separation Values
File Handling → CSV file read write and search
Included
ID 6492 · 2021 · 1 mark(s)
Which of the following is not a function/method of csv module in Python?
a) read()
b) reader()
c) writer()
d) writerow()
File Handling → CSV file read write and search
Included
ID 6521 · 2021 · 1 mark(s)
Rohit, a student of class 12, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code to create a CSV File 'Student.csv' with content:
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A
Incomplete Code:
import _____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [_____] #Statement-4
data.append(_____) #Statement-5
stuwriter._____(data) #Statement-6
fh.close()
Identify the suitable code for blank space in the line marked as Statement-1.
a) csv file
b) CSV
c) csv
d) cvs
File Handling → CSV file read write and search
Included
ID 6522 · 2021 · 1 mark(s)
Identify the missing code for blank space in line marked as Statement-2.
(Refer to the CSV file creation code in the case study: fh = open(_____, _____, newline=''))
a) "Student.csv","wb"
b) "Student.csv","w"
c) "Student.csv","r"
d) "Student.cvs","r"
File Handling → CSV file read write and search
Included
ID 6523 · 2021 · 1 mark(s)
Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3.
(Refer to the CSV file creation code in the case study: stuwriter = csv._____)
a) reader(fh)
b) reader(MyFile)
c) writer(fh)
d) writer(MyFile)
File Handling → CSV file read write and search
Included
ID 6524 · 2021 · 1 mark(s)
Identify the suitable code for blank space in line marked as Statement-4.
(Refer to the CSV file creation code in the case study: rec = [_____])
a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
b) ROLL_NO, NAME, CLASS, SECTION
c) 'roll_no','name','Class','section'
d) roll_no,name,Class,section
File Handling → CSV file read write and search
Included
ID 6525 · 2021 · 1 mark(s)
Identify the suitable code for blank space in the line marked as Statement-5.
(Refer to the CSV file creation code in the case study: data.append(_____) )
a) data
b) record
c) rec
d) insert
File Handling → CSV file read write and search
Included
ID 6544 · 2022 · 1 mark(s)
Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
Reason (R): The information is organized with one record on each line and each field is separated by comma.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True
File Handling → CSV file read write and search
Included
ID 6565 · 2022 · 5 mark(s)
What is the advantage of using a csv file for permanent storage?
Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file 'record.csv'. Each record consists of a list with field elements as empid, name and mobile to store employee id, employee name and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file named 'record.csv'.
(ii) search() – To display the records of the furniture whose price is more than 10000.