TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files

Question 1.
What is purpose of CSV file?
Answer:

  1. CSV is a simple file format used to store data, such as spreadsheet or database.
  2. They are plain text and easier to import into a spreadsheet or another storage database, regardless of the specify software you are using.

Question 2.
What do you know about a CSV file?
Answer:
A CSV file is also known as a flat File. File in the CSV format can be imported to and exported from programs that store data in tables, such as Microsoft Excel or open office calc.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 3.
How will you create new a CSV file?
Answer:

  1. To create a CSV file in Notepad, First open a new file using
    File → New or ctrl + N
  2. Then enter the data you want the file to contain, separating each value with a comma and each row with a new line.

Question 4.
What ¡s a dialect?
Answer:

  1. A dialect describes the format of the CSV file that is to be read.
  2. In dialect the parameter “Skip initial space” is used for removing whitespaces after the delimiter.

Question 5.
What is difference CSV.writer ( ) and writerow ( ) methods?
Answer:

CSV writerow ( )  writerow ( )
The CSV.writerow ( ) method returns a wirter object which converts the user’s data into delimited string on the given file like object.  The writerow ( ) method writes a row of data into the specified file.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 6.
What is the use of Line Terminator in CSV file?
Answer:

  1. A Line Terminator is a string used to terminate lines produced by writer. The default value is \r or \n,
  2. We can write CSV file with a line terminator in python by registering new dialects using csv.register dialect ( ) class of csv module.

Question 7.
What is CSV module?
Answer:

  1. The CSV module will be able to read and write the vast majority of CSV files.
  2. CSV module which gives the python programmer the ability to parse.

Question 8.
How can you open a CSV files?
Answer:
We can open CSV files in a spread sheet program like Microsoft Excel or in a Text editor or through a data base which make them easier to read.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 9.
What is use of Skipinitial space?
Answer:
In dialects the parameter “Skipinitial Space” is used for removing whitespaces after the delimiter.

Question 10.
What is a list?
Answer:

  1. A list is a data structure in python that is a module, or changeable, ordered sequence of elements.
  2. List literals are written square brackets [ ]. List work similarly to strings.

Question 11.
What is difference between sorted ( ) and sort ( ) method?
Answer:

  1. The sorted ( ) method sorts the elements of a given item in a specific order Ascending or Descending.
  2. Sort ( ) method which performs the same way as sorted ( ). Only difference, sort () method does not return any value and changes the original list itself.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 12.
What is an ordered Diet?
Answer:

  1. An ordered Diet is a dictionary subclass which saves the order in which its contents are added.
  2. To remove the ordered Diet use diet ( ).

Question 13.
Explain the CSV module’s Reader Function.
Answer:
(i) csv.reader ( ) function is designed to take each line of the file and make a list of all columns.
(ii) Using this function one can read data from csv files of different formats like quotes (“ ”), pipe (|) and comma (,).
(iii) The syntax for csv.reader is csv.reader (fileobject, delimiter, fmtparams)
Where
File object – Passes the path and mode .
delimiter – an optional parameter containing the standard dialects.
fmtparams – optional parameter with default values of the dialects.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 14.
What are different types in CSV files while writing Data?
Answer:

  1. Creating a new normal CSV file.
  2. Modifying an Existing file.
  3. Writing on a CSV file with Quotes.
  4. Writing on a CSV file with Custom Delimiters.
  5. Writing on a C S V file with Lineterminator.
  6. Writing on a CSV file with Quotechars.
  7. Writing CSV file into a Dictionary.
  8. Getting Data at Runtime and Writing in a file.

Question 15.
Write a program to sort a list using next( ) method.
Answer:
# sort a selected column given by user leaving the header column
import csv
inLile= ‘c:\\pyprg\\sample6.csv’
python file
F=open(inFile,‘r’)
reader = csv.reader(F)
next(reader)
arrayValue = [ ]
a = int(input (“Enter the column number 1 to 3:-”))
for row in reader:
arrayValue.append(row[a])
array Value. sort( )
for row in array Value:
print (row)
F.elose( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 16.
Write the different types writing Data into in csv files.
Answer:
(i) Creating A New Normal CSV File:
This method, we can create a normal csv file using writer ( ) method of csv module having default delimiter comma (,).

(ii) Modifying An existing file:
Making some changes in the data of existing file or adding more data is called modification.

(iii) Writing on A CSV file with Quotes:
We can write the CSV file with quotes, by registering new dialects using csv. register_dialect ( ) class of CSV module.

(iv) Writing on A CSV File with custom Delimiters:
A diameter is a string used to separate fields. The default value is comma (,).

(v) CSV File with A Line Terminator:
A Line Terminator is a string used to terminate lines product by writer. The default values is \r or \n.

(vi) CSV File with quotes character:
The csv file with custom quote characters, by registering new dialects using csv. refister dialect ( ) class of csv module.

(vii) Writing CSV File into A Dictionary:
Using Dictwriter ( ) Class of csv module, we can write a csv file into a dictionary. It creates an object which maps data into a dictionary. The keys are given by the fieldnames parameter.

(viii) Getting Data At Runtime and Writing it in a CSV file:
We can accept data thought key board and write in to a csv file.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 17.
What is CSV File?
Answer:

  1. CSV – Comma Separated Values.
  2. CSV module which gives the python programmer the ability to parse CSV files.
  3. A CSV file is a human readable text file where each line has a number of fields, separated by commas or some other delimiter.

Question 18.
Mention the two ways to read a CSV file using Python.
Answer:
There are two ways to read a CSV file.

  • Use the CSV module’s reader function.
  • Use the DictReader class.

Question 19.
Mention the default modes of the File.
Answer:

  1. ‘t’ – open the text mode in default.
  2. The default is reading in text mode, while reading from the file the data would be in the format of strings.
  3. ‘r’- Open the file for reading in default.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 20.
What is use of nextQ function?
Answer:

  1. CSV file data for a selected column for sorting, the row heading is also get sorted, to avoid that the first row should be skipped.
  2. This can be done by using the command next ( ) function.

Question 21.
How will you sort more than one column from a csv file?Give an example statement.
Answer:
To sort by more than one column we can use itemgetter with multiple indices.
Eg:
Operator. itemgetter( 1,2)
The first and second rows are sorted from CSV file and displayed in ascending order.

Question 22.
Write a note on open( ) function of python. What is the difference between the two methods?
Answer:
Python has a built – in function open ( ) to open a file. This function returns a file object, also called a handle, as it is used to read or modify the file accordingly.
Eg:
>>> c = open (“stud.txt”)
# open file in current directory
>>> c = open (‘D:\\prg\\Temp\\stud.csv’’) Specifing full path
Whether you want to read ‘r’, write ‘w’ or append ‘a’ to the file, also specify the opening file.
Python has two methods
(i) readable () – Returns True if the stream can be read from.
(ii) readline (n = -1) – Read and return a list of lines from the file.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 23.
Write a Python program to modify an existing file.
Answer:
The following program modify the “student, csv” file by modifying the value of an existing row in student.csv
import csv
row = [‘3’, ‘Meena’,’Bangalore’]
with open(‘student.csv’, ‘r’) as readFile:
reader = csv.reader(readFile)
lines = list(reader)
# list()- to store each row of data as a list
lines[3] = row
with open(‘student.csv’, ‘w’) as writeFile:
# returns the writer object which converts the user data with delimiter
writer = csv.writerfwriteFile)
#writerows( )method writes tnultiple rows to a csv file
writer . writerows(lines)
readFile.close( )
writeFile.close( )

Question 24.
Write a Python program to read a CSV file with default delimiter comma (,).
Answer:
The following program read a file called “sample 1 .csv” with default delimiter comma (,) and print row by row.
importing csv
import csv
#opening the csv file which is in different location with read mode
with open(‘c:\\pyprg\\samplel.csv’, ‘r’) as
F:
#other way to open the file is f= (‘c:\\pyprg\\ samplel.csv’, ‘r’)
reader = csv.reader(F)
# printing each line of the Data row by row print(row)
F.close( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 25.
What is the difference between the write mode and append mode.
Answer:

  1. Write (w) and Append (a) mode, while opening a file are almost the same.
  2. Append mode is used to append or add data to the existing data of file, if any.
  3. Hence, when you open a file in Append (a) mode, the cursor is positioned at the end of the present data in the file.

Question 26.
What is the difference between reader( ) and DictReader( ) function?
Answer:

  1. The main difference between the csv.reader( ) and DictReader( ) is in simple terms csv.reader and csv.writer work with list/tuple.
  2. While csv.DictReader and csv.Dictwriter work with dictionary.
  3. csv.DictReader and csv.dietwriter take additional argument fieldnames that are used as dictionary keys.
  4. To read a csv file into a dictionary can be done by using DictReader class of csv module which works similar to the reader( ) class but creates an object which maps data to a dictionary.

Question 27.
Differentiate Excel file and CSV file.
Answer:

Excel  CSV file
Excel is a binary file that holds information about all the worksheets in a file, including both content and formatting.  CSV format is a plain text format with a series of values separated by commas.
XLS files can only be read by applications that have been especially written to read their format, and can only be written in the same way.  CSV can be opened with any text editor in Windows like notepad, MS Excel, OpenOffice, etc.
Excel is a spreadsheet that saves files into its own proprietary format viz. xls or xlsx.  CSV is a format for saving tabular information into a delimited text file with extension .csv
Excel consumes more memory while importing data.  Importing CSV files can be much faster, and it also consumes less memory.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 28.
Tabulate the different mode with its meaning.
Answer:
r – Open file for reading
w – Open file for writing
x – Open file for exclusive creation
a – Open for appending
t – Open in text mode
b – Open in binary mode
t – Open a file for updating.

Question 29.
Write the different methods to read a File in Python.
Answer:
(i) CSV module’s Reader function:
The reader function is designed to take each line of the file and make a list of all columns.
Using this method one can read data from csv files of different formats like quotes (“ ”), pipe (|) and column (,).
The syntax is csv.reader (file object, delimiter, fmt params)

(ii) Read a specific column in a file:
To get the specific columns like only item.
Eg:
readfile = csv.reader (f)
for col in readfile:
print col[0], col[3] f.close ()
(iii) Read a csv file and store It In A list:
are going to read a csv file and the contents of the file will be stored as a list.
The syntax for storing in the List is
list = [ ]
list.append (element)

(iv) Reading csv file Into a Dictionary:
To read a csv file into a dictionary can be done by using DictReader class of csv module which works similar to the reader ( ) class but creates an object which maps data to a dictionary. The main difference is in simple terms csv.reader () and DictReader( )is in simple terms csv.reader and csv.writer work with list/tuple, while csv.DictReader and csv.Dictwriter work with dictionary.

(v) Reading csv file with user Defined Delimiter into a dictionary:
We can register new dialects and use it in the DictReader( ) methods.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 30.
Write a Python program to write a CSV File with custom quotes.
Answer:
import csv
info = [[‘SNO\ ‘Person’, ‘DOB’],
[‘1’, ‘Madhu’, ‘18/12/2001’],
[‘2’, ‘Sowmiya’,’ 19/2/1998’],
[‘3’, ‘Sangeetha’,’20/3/1999’],
[‘4’, ‘Eshwar’, ‘21/4/2000’],
[‘5’, ‘Anand’, ‘22/5/2001’]]
csv.register_dialect(‘myDialect’, quoting = csv.QUOTEALL)
with open(‘c:\\pyprg\\chl3\\person.csv’,‘w’) asf:
writer = csv.writer(f, dialect=‘myDialect’) for row in info: writer, writero w(row)
. f.close( )

Question 31.
Write the rules to be followed to format the data in a CSV file.
Answer:
Rules to be followed to format data in a CSV . file:
(i) Each record (row of data) is to be located on a separate line, delimited by a line break by pressing enter key.
Eg:
xxx,yyy TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1
TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1 denotes enter Key to be pressed

(ii) The last record in the file may or may not have an ending line break.
Eg:
PPP, qqq TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1
yyy, xxx

(iii) The header will contain names corresponding to the fields in the file and should contain the same number of fields as the records in the rest of the file.
Eg:
fieldnamel ,field_name2, field_name3 TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1
aaa,bbb,ccc TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1
zzz,yyy,xxx CRLF( Carriage Return and Line Feed)

(iv) Within the header and eafeh record, there may be one or more fields, separated by commas. Spaces are considered part of a field and should not be ignored. The last field in the record must not be followed by a comma.
For example: Red , Blue

(v) Each field may or may not be enclosed in double quotes. If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.
Eg:
“Red”,’’Blue”,”Green” TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 1
Black,White,Yellow

(vi) Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.
Eg:
Red, ” , “Blue CRLF
Red, Blue , Green

(vii) If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be preceded with another double quote.
Eg:
“Red, ” “Blue”, “Green”,
, , White

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 32.
Write a Python program to read the following Namelist.
Answer:

TN State Board 12th Computer Science Important Questions Chapter 13 Python and CSV Files 2

# program Namelist.csv file alphabetical order.
import.csv
infile = ‘c:\\pyprg\\Namelist.csv’

Python file
F = open (in file,’r’)
reader = csv.reader (F)
next (reader)
array value = [ ]
for row in reader:
array value.append (row)
array value.sort ()
for row in array value:
print (row)
F. close ( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 33.
Write a Python program to accept the name and five subjects mark of 5 students. Find the total and store all the details of the students in a CSV file.
Answer:
import csv
with open (‘c:\\pyprg\\school\\student. csv’,w) as f:
w – csv.writer (f) ans = ‘y’
while (ans =r-=‘y’): name = input (“Name”) subl = input (“subject 1 mark”) sub2 = input (“subject 2 mark”) sub3 = input (“subject 3 mark”) sub4 = input (“subject 4 mark”) sub5 = input (“subject 5 mark”)
Total = 0
Total = subl+sub2+sub3+sub4+sub5
w.writerow ([name, subl, sub2, sub3, sub4, sub5,Total])
ans = input (“Do you want more y/n”)
F = open (‘c:\\pyprg\\school\\stuent.csvYr’) reader = csv.reader (F) for row in reader:
Print (row)
F.close ( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Choose the best answer:

Question 1.
What is extension filename of CSV?
(a) .txt
(b) .xls
(c) .csv
(d) .py
Answer:
(c) .csv

Question 2.
What is the shortcut key used to open a new CSV file in notepad?
(a) Ctrl + O
(b) Ctrl + N
(c) Ctrl + N
(d) Alt + O
Answer:
(b) Ctrl + N

Question 3.
Each record is to be located on a separate line, delimited by a line break by pressing:
(a) Enter key
(b) Ctrl key
(c) Alt key
(d) Esc key
Answer:
(a) Enter key

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 4.
Which CSV file will be opened default?
(a) Open office calc
(b) MS Excel
(c) Star office calc
(d) Launch Excel
Answer:
(b) MS Excel

Question 5.
Which of the following is open the text mode?
(a) ‘r’
(b) ‘x’
(c) ‘a’
(d) ‘t’
Answer:
(d) ‘t’

Question 6.
Which is default file mode to open a file for reading?
(a) ‘r’
(b) ‘x’
(c) ‘a’
(d) ‘t’
Answer:
(a) ‘r’

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 7.
Which statement is best way to do ensures that the file is closed?
(a) With
(b) Exit
(c) Stop
(d) Close
Answer:
(a) With

Question 8.
A dialect is a:
(a) Class
(b) Object
(c) Method
(d) Function
Answer:
(a) Class

Question 9.
Which delimiter is considered as column separator?
(a) = (equal)
(b) , (comma)
(c) | (pipe)
(d) & (amphersand)
Answer:
(c) | (pipe)

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 10.
Which operator is used to set more than one column in csv file?
(a) Sort record
(b) item getter
(c) data getter
(d) column getter
Answer:
(b) item getter

Question 11.
Which class can be done to read csv file into a dictionary?
(a) dict( )
(b) Read
(c) DictReader
(d) Reader
Answer:
(c) DictReader

Question 12.
Which method is used to writes all the data in to the new csv file?
(a) write rows ( )
(b) write row ( )
(c) store rows ( )
(d) store row ( )
Answer:
(a) write rows ( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 13.
What is called to add more data in the existing csv file?
(a) Append
(b) Adding
(c) Modification
(d) Writing
Answer:
(c) Modification

Question 14.
Which of the following known as default line terminator to write csv file?
(a) ‘/r’
(b) ‘\n’
(c) ‘\w’
(d) Both (a) and (b)
Answer:
(d) Both (a) and (b)

Question 15.
Which function is used to print the data in dictionary format without order?
(a) DictReader ( )
(b) diet ( )
(c) function diet ( )
(d) Dictwriter ( )
Answer:
(b) diet ( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 16.
Which is the default mode of csv file in reading and writing?
(a) text mode
(b) binary mode
(c) formated mode
(d) pdf mode
Answer:
(a) text mode

Question 17.
Python has a garbage collector to clean up unreferenced:
(a) variables
(b) objects
(c) method
(d) function
Answer:
(b) objects

Question 18.
Which is used for removing white spaces after the delimiter in csv file?
(a) “Skip initial space”
(b) “Skip”
(c) “space”
(d) “initial space”
Answer:
(a) “Skip initial space”

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 19.
csv.reader and csv.writer work with:
(a) list
(b) tuple
(c) a or b
(d) None
Answer:
(c) a or b

Question 20.
Adding a new row at the end of file is called:
(a) Adding a row
(b) Appending a row
(c) Inserting a row
(d) Modifying a row
Answer:
(b) Appending a row

Question 21.
Match the following:

(i) ‘r’  A. updating mode
(ii) ‘w’  B. appending mode
(iii) ‘a’  C.  writing mode
(iv) ‘t’  D. reading mode

(a) (i) – D, (ii) – C , (iii) – B, (iv) – A
(b) (i) – D, (ii) – B, (iii) – A, (iv) – C
(c) (i) – B, (ii) – A , (iii) – C, (iv) – D
(d) (i) – B, (ii) – C, (iii) – D, (iv) – A
Answer:
(a) (i) – D, (ii) – C , (iii) – B, (iv) – A

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 22.
Match the following:

(i) ‘w’  A. add data end of file
(ii) ‘a’  B. write a new file
(iii) write row ( )  C. write all rows
(iv) write rows ( )  D. write one row

(a) (i) – B, (ii) – A, (iii) – D, (iv) – C
(b) (i) – B, (ii) – D, (iii) – C, (iv) – A
(c) (i) – D, (ii) – C, (iii) – A, (iv) – B
(d) (i) – D, (ii) – A, (iii) – B, (iv) – C
Answer:
(a) (i) – B, (ii) – A, (iii) – D, (iv) – C

Question 23.
Match the following:

(i) close ( )  A. Convert delimited strings
(ii) DictReader  ( )  B. print the data
(iii) Function diet ( )  C. tied with the file
(iv) csv. writer ( )  D. creates an object

(a) (i) – C, (ii) – B , (iii) – A, (iv) – D
(b) (i) – C, (ii) – D, (iii) – B, (iv) – A
(c) (i) – B, (ii) – A, (iii) – D, (iv) – C
(d) (i) – B, (ii) – D, (iii) – C, (iv) – A
Answer:
(b) (i) – C, (ii) – D, (iii) – B, (iv) – A

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 24.
Choose the incorrect pair:
(a) CSV – comma separated value
(b) XLS – excel sheets
(c) CRLF – control Return and Line Feed
(d) PY – Python
Answer:
(c) CRLF – control Return and Line Feed

Question 25.
Choose the correct pair:
(a) ‘x’ – open binary mode
(b) ‘b’ – open for writing
(c) ‘t’ – open for updating
(d) ‘t’ – open for reading
Answer:
(c) ‘t’ – open for updating

Question 26.
Choose the incorrect statement:
(a) Excel is binary file in python.
(b) csv format is a plain text.
(c) Import csv files can be much slower.
(d) CSV is a format for saving tabular information.
Answer:
(c) Import csv files can be much slower.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 27.
Choose the incorrect statement:
(a) Files saved in excel cannot be opend or edited by text editors.
(b) CSV file can be store charts and graphs.
(c) A CSV file is also known as a flat file.
(d) A CSV file is a text file.
Answer:
(b) CSV file can be store charts and graphs.

Question 28.
Choose the correct statement:
(a) The last record in the CSV file may or may not have an ending line break.
(b) In CSV file, each field must be enclosed in single quotes.
(c) In CSV file, double-quotes should not be used to enclosed fields.
(d) In CSV file, each record is to be located on a single line.
Answer:
(a) The last record in the CSV file may or may not have an ending line break.

Question 29.
Pick the odd one out.
(a) MS Excel
(b) Open office calc
(c) Python
(d) Star office calc
Answer:
(c) Python

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 30.
Pick the odd one out
(a) (“ ”) quotes
(b) (|) pipe
(c) (,) comma
(d) (;) semicolon
Answer:
(d) (;) semicolon

Question 31.
Assertion (A):
The commas that are part of your data will then be kept separate from the commas which delimit the fields themselves.
Reason (R):
If the fields of data in your CSV file contain commas, you can protect them by enclosing those data fields in double-quotes (“ ”)
(a) Both A and R are True and R is the correct explanation for A.
(b) Both A and R are True but R is not the correct explanation for A.
(c) A is true But R is False.
(d) A is False But R is True.
Answer:
(a) Both A and R are True and R is the correct explanation for A.

Question 32.
Assertion (A):
In CSV files, a delimiter is a string used to separate fields.
Reason (R):
The default value is (;) semicolon.
(a) Both A and R are True and R is the correct explanation for A.
(b) Both A and R are True but R is not the correct explanation for A.
(c) A is true But R is False.
(d) A is False But R is True.
Answer:
(c) A is true But R is False.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 33.
Which spreadsheet, by default the CSU file will be opened?
(a) Open office calc
(b) Star calc
(c) MS Excel
(d) All of these
Answer:
(c) MS Excel

Question 34.
Which of the mode for open a file for writing?
(a) ‘r’
(b) ‘w’
(c) ‘x’
(d) ‘o’
Answer:
(b) ‘w’

Question 35.
Which of the mode for open a file for exclusive creation?
(a) ‘r’
(b) ‘w’
(c) ‘x’
(d) ‘o’
Answer:
(c) ‘x’

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 36.
Which of the mode to open for appending at the end of the file without truncating it?
(a) ‘a’
(b) ‘t’
(c) ‘b’
(d) ‘+’
Answer:
(a) ‘a’

Question 37.
Which of the mode to open in binary mode?
(a) ‘a’
(b) ‘f
(c) ‘b’
(d) ‘+’
Answer:
(c) ‘b’

Question 38.
Which of the mode to open a file for updating?
(a) ‘a’
(b) ‘t’
(c) ‘b’
(d) ‘+’
Answer:
(d) ‘+’

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 39.
How many ways to read a CSV file?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

Question 40.
How many types of modes can be used while opening a CSV file?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(b) 3

Question 41.
Which of the following is not type of mode while opening a CSV file?
(a) w
(b) r
(c) a
(d) m
Answer:
(d) m

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 42.
When reading CSV file in text mode, the format of data should be:
(a) string
(b) integer
(c) character
(d) float
Answer:
(a) string

Question 43.
How many ways are available to write or ‘ modify the existing CSV file?
(a) 2
(b) 4
(c) 6
(d) 8
Answer:
(d) 8

Question 44.
What is extension of CSV file?
(a) .cs
(b) .cv
(c) .csv
(d) .c
Answer:
(c) .csv

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 45.
A CSV file is also known as a:
(a) Flat File
(b) 3D File
(c) String File
(d) Random File
Answer:
(a) Flat File

Question 46.
The expansion of CRLF is:
(a) Control Return and Line Feed
(b) Carriage Return and Form Feed
(c) Control Router and Line Feed
(d) Carriage Return and Line Feed
Answer:
(d) Carriage Return and Line Feed

Question 47.
Which of the following module is provided by Python to do several operations on the CSV files?
(a) py
(b) xls
(c) csv
(d) os
Answer:
(c) csv

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 48.
Which of the following mode is used when dealing with non-text files like image or exe files?
(a) Text mode
(b) Binary mode
(c) xls mode
(d) csv mode
Answer:
(b) Binary mode

Question 49.
The command used to skip a row in a CSV file is:
(a) next( )
(b) skip( )
(c) omit( )
(d) bounce( )
Answer:
(a) next( )

Question 50.
Which of the following is a string used to terminate lines produced by writer( )method of csv module? .
(a) Line Terminator
(b) Enter key
(c) Form feed
(d) Data Terminator
Answer:
(a) Line Terminator

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 51.
What is the output of the following program? import csv
d=csv.reader(open(‘c:\PYPRG\ch 13\city. csv’))
next(d)
for row in d:
print(row)
if the file called “city.csv” contain the following details
chennai, mylapore mumbai, andheri
(a) chennai,mylapore
(b) mumbai,andheri
(c) chennai-mumbai
(d) chennai,mylapore-mumbai,andheri
Answer:
(b) mumbai,andheri

Question 52.
Which of the following creates an object which maps data to a dictionary?
(a) listreader( )
(b) reader( )
(c) tuplereader( )
(d) DictReader ( )
Answer:
(d) DictReader ( )

Question 53.
Making some changes in the data of the existing file or adding more data is called:
(a) Editing
(b) Appending
(c) Modification
(d) Alteration
Answer:
(c) Modification

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 13 Python and CSV Files

Question 54.
What will be written inside the file test.csv using the following program?
import csv
D = [[‘Exam’],[‘Quarterly’],[‘Halfyearly’]]
csv.register_dialect( ‘ M ’ ,lineterminator= V)
with open(‘c:\pyprg\chl3\line2.csv’,‘w’)asf:
wr = csv.writer(f,dialect=‘M’)
wr.writerows(D)
f.close( )
(a) Exam Quarterly Halfyearly
(b) Exam Quarterly Halfyearly
(c) E
Q
H
(d) Exam,
Quarterly,
Halfyearly
Answer:
(d) Exam,
Quarterly,
Halfyearly

TN Board 12th Computer Science Important Questions