CSV in Python class 12 Important Questions and Answers

CSV in Python class 12 offers assignments and questions answers on data file handling in python CBSE class 12 computer science.

CSV in Python class 12 Questions and Answers

Here in we go for CSV in Python class 12 questions and answers.

Objective type questions

Fill in the blanks

[1] A _________ is a file format which stores records separated by comma.


[2] One row of CSV file can be considered as _______ in terms of database.


[3] The CSV files can be operated by __________ and ____________ software.

Text Editor, Spreadsheet or Notepad, MS Excel

[4] The writerow() function is a part of _________ module.


[5] A _____ function allows to write a single record into each row in CSV file.


[6] The _________ parameter of csv.reader() function is used to set a specific delimiter like a single quote or double quote or space or any other character.


[7] A ________ is a parameter of csv.reader() function that accpets the keyword arguments.


[8] When you read csv file using csv.reader() function it returns the values in _______ object.

nested list

[9] A ________ parameter is used to quote all fields of csv files.


[10] You can specify a quote character using _______ through writer function.


[11] The ____________ parameter instructs writer objects to only quote those fields which contain special characters such as delimiterquotechar or any of the characters in lineterminator.


[12] To avoid quote fields in csv.writer() function, use _________ parameter.


[13] If you want to change a default delimiter of csv file, you can specify ________ parameter.


[14] CSV module allows to write multiple rows using ____________ function.


[15] ___________ instances or objects return by the writer function.


True/False – CSV in Python class 12

[1] Each row read from the csv file is returned as a list of strings.


[2] You can import csv module functions in following manner:

from csv import writerow, reader


[3] The csv.QUOTE_NONNUMERIC is used to quotes all kind of data.


[4] When csv.QUOTE_NONE is used with writer objects you have to specify the escapechar option parameter to writerow() function.


[5] You cannot change the by default comma as a value separater.


[6] The quotechar function must be given any type of character to separate values.


[7] The default line terminator is \n in csv file.


[8] The write row function creates header row in csv file by default.


[9] You cannot insert multiple rows in csv file using python csv module.


[10] In csv file, user can insert text values and date values with single quote like MySQL.


MCQs/One word Answer Questions – CSV in Python class 12

  1. Expand: CSV
    • Comma Separated Value
  2. Which of the following module is required to import to work with CSV file?
    1. File
    2. CSV
    3. pandas
    4. numpy
  3. Which of the following is not a function of csv module?
    1. readline()
    2. writerow()
    3. reader()
    4. writer()
  4. The writer() function has how many mandatory parameters?
    1. 1
    2. 2
    3. 3
    4. 4
  5. Name the function which used to write a row at a time into CSV file.
    • writerow()
  6. Which of the following parameter needs to be added with open function to avoid blank row followed file each row in CSV file?
    1. qoutechar
    2. quoting
    3. newline
    4. skiprow
  7. Anshuman wants to separate the values by a $ sign. Suggest to him a pair of function and parameter to use it.
    1. open,quotechar
    2. writer,quotechar
    3. open,delimiter
    4. writer, delimiter
  8. Which of the following is tasks cannot be done or difficult with CSV module?
    1. Data in tabular form
    2. Uniqueness of data
    3. Saving data permanently
    4. All of these
  9. Which of the following is by default quoting parameter value?
    1. csv.QUOTE_MINIMAL
    2. csv.QUOTE_ALL
    4. csv.QUOTE_NONE
  10. Which of the following is must be needed when csv.QUOTE_NONE parameter is used?
    1. escapechar
    2. quotechar
    3. quoting
    4. None of these

Descriptive Questions CSV in python class 12

[1] Write the functions required to handle CSV files.

To handle CSV files following function required:

  1. Open()
  2. reader()
  3. writer()
  4. writerow()
  5. close()

[2] Write to ways to import a csv module.

  1. import csv
  2. from csv import *

[3] Explain following functions with example.

  1. reader()
  2. writer()
  3. writerow()

Refer csv in python class 12 for answer

Case study based questions – CSV in Python class 12

[4] Write python code to create a header row for CSV file “students.csv”. The column names are : Adm.No, StudentName, City, Remarks

Creating a header row is one of the most important aspects of CSV in python class 12. Use the following code to do so.

from csv import writer
f = open("students.csv","w")
dt = writer(f)

[5] Observe the following code and fill in the given blanks:

import csv
with _________ as f:
    r = csv.______(f)
    for row in ______:
        print(_____) #4
  1. open(“data.csv”)
  2. reader
  3. r
  4. row

[6 Write steps to print data from csv file in list object and support your answer with example.

  1. Import csv module – import csv
  2. Open the csv file in reading mode – f = open(“demo.csv”,”r”)
  3. Use list object to store the data read from csv using reader – data = csv.reader(f)
  4. close the csv file – f.close()
  5. print the data object – print(data)

[6] How to print following data for cust.csv in tabular form usig python code?

SNoCustomer NameCityAmount
from csv import reader
f = open("cust.csv","r")
    dt = reader(f)
    data = list(dt)
    for i in data:
        for j in i:
            print('\t|',j,end=" ")

[7] Write code to insert multiple rows in the above csv file.

from csv import writer
with open("cust.csv","a",newline="\n")
 as f:
    dt = writer(f)
    while True:
        sno= int(input("Enter Serial No:"))
        cust_name = input("Enter customer name:")
        city = input("Enter city:")
        amt = int(input("Enter amount:"))
        dt.writerow([sno, cust_name, city, amt])
        print("Record has been added.")
        print("Want to add more record?Type YES!!!")
        ch = input()
        ch = ch.upper()
        if ch=="YES":

[8] Write code to delete a row from csv file.

import csv
record = list()
custname= input("Please enter a customer name to delete:")
with open('cust.csv', 'r') as f:
    data = csv.reader(f)
    for row in data:
        for field in row:
            if field == custname:
with open('cust.csv', 'w') as f:
    writer = csv.writer(f)

Share this article with your friends and classmates.

Ask your doubt in comment section.

Thank you for reading this article CSV in Python class 12 questions and answers.

Attend this quiz to check your knowledge.

One thought on “CSV in Python class 12 Important Questions and Answers”

Leave a Reply