12th Standard Syllabus & Materials
12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set C
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set B
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set A
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set C

Published on: 06/11/2019
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test1.
__________ is typically interpreted language.
Python
Java
C++
None of these
2.
Which of the following is not a python module?
Sys
OS
Getopt
g++
3.
Which of the following is needed to run a c++ program on windows?
m++
g++
ghre++
f++
4.
SWIG expansion is
Simplified Wrapper Interface Generator
Software Wrapper Information Generator
Simplified Wrapper Interface Generator
System Wrapper Interface Generator
5.
Which of the following language used automatic garbage collection?
C++
Java
C
Python
6.
In which language datatype or not required while declare variable?
C++
C
Java
Python
7.
Which of the following is not a compiled statically typed language?
C++
Java
Python
All of these
8.
In CSV file, if more than one column can be sorted using
sorter ( )
multisort ( )
itemgetter ( )
morecolumns ( )
9.
List literals are enclosed with
{ }
( )
< >
[ ]
10.
How many formats in which CSV file data can be read?
3
2
4
5
11.
Which of the following format(s) the CSV files data can be read?
Quotes
Pipe
Comma
all of these
12.
Which python file mode open a file for exclusive creation?
'x'
'w'
't'
'a'
13.
Which file mode creates a new file if does not exist?
'n'
'r'
'w'
'x'
14.
CSV file can be opened in
Text mode
Binary mode
Application mode
a or b
15.
How many steps are there to do CSV file operations using python?
2
3
4
5
16.
How many ways to read a CSV file?
2
3
4
Only one
17.
Fields containing line breaks denoted by
CSV
XLS
CLRF
CRLF
18.
CSV means
Condition separated values
Colon separated values
C++ solution values
Comma separated values
19.
Which of the following gives the python programmer the ability to parse CSV files?
CSV data
CSV module
CSV sheet
CSV flat file
20.
What does __name__ contains?
c++ filename
main() name
python filename
os module name
21.
Which of the following can be used for processing text, numbers, images, and scientific data?
HTML
C
C++
PYTHON
22.
getopt() will return an empty array if there is no error in splitting strings to
argv variable
opt variable
args variable
ifile variable
23.
24.
The expansion of API is
Application Programming Interpreter
Application Programming Interface
Application Performing Interface
Application Programming Interlink
25.
Which of the following is not a scripting language?
JavaScript
PHP
Perl
HTML
26.
27.
Which of the following creates an object which maps data to a dictionary?
listreader()
reader()
tuplereader()
DictReader ()
28.
Which of the following is a string used to terminate lines produced by writer()method of csv module?
Line Terminator
Enter key
Form feed
Data Terminator
29.
The expansion of CRLF is
Control Return and Line Feed
Carriage Return and Form Feed
Control Router and Line Feed
Carriage Return and Line Feed
30.
A CSV file is also known as a ….
Flat File
3D File
String File
Random File
31.
What is the use of GNU C complier?
32.
What is the use of CSV file?
33.
34.
Write the expansion of (i) SWIG (ii) MinGW
35.
What is the theoretical difference between Scripting language and other programming language?
36.
What is use of next() function?
37.
Mention the default modes of the File.
38.
What is CSV File?
39.
How to import modules in python?
40.
List the commonly used python interfaces.
41.
What are the different ways of reading a CSV file using reader ( ) method?
42.
How will you create CSV normal file?
43.
Identify the module, operator, definition name for the following
welcome.display().
44.
Differentiate PYTHON and C++.
45.
Write a Python program to read a CSV file with default delimiter comma (,).
46.
Write a note on open() function of python. What is the difference between the two methods?
47.
Explain the commands for wrapping C++ code.
48.
How will you write Dictionary into CSV file with custom dialects?
49.
Write a program to read a specific column in a CSV file.
50.
Write a Python program to execute the following c++ coding.
#include <iostream>
using namespace std;
int main()
{ cout<<“WELCOME”;
return(0);
}
The above C++ program is saved in a file welcome.cpp
51.
Write the syntax for getopt( ) and explain its arguments and return values.
52.
53.
Write any 5 features of Python.
54.
Write the rules to be followed to format the data in a CSV file.
55.
Write the different methods to read a File in Python.
56.
Differentiate Excel file and CSV file.
1.
(a)
Python
2.
(d)
g++
3.
(b)
g++
4.
(a)
Simplified Wrapper Interface Generator
5.
(d)
Python
6.
(d)
Python
7.
(c)
Python
8.
(a)
sorter ( )
9.
(d)
[ ]
10.
(a)
3
11.
(d)
all of these
12.
(d)
'a'
13.
(c)
'w'
14.
(d)
a or b
15.
(b)
3
16.
(a)
2
17.
(d)
CRLF
18.
(d)
Comma separated values
19.
(b)
CSV module
20.
(a)
c++ filename
21.
(d)
PYTHON
22.
(a)
argv variable
23.
(a)
24.
(b)
Application Programming Interface
25.
(d)
HTML
26.
(c)
27.
(d)
DictReader ()
28.
(a)
Line Terminator
29.
(d)
Carriage Return and Line Feed
30.
(a)
Flat File
31.
g++ is a program that calls GCC (GNU C Compiler) and automatically links the required C++library files to the object code
32.
CSV is a simple file format used to store tabular data, such as a spreadsheet or database. Since they're plain text, they're easier to import into a spreadsheet or another storage database, regardless of the specific software
33.
34.
(i) SWIG - Simplified Wrapper Interface Generator
(ii) MinGW - Minimalist GNU for Windows
35.
(i) The theoretical difference between the two is that scripting languages do not require the compilation step and are rather interpreted.
(ii) For example, normally, a C++ program needs to be compiled before running whereas, a scripting language like JavaScript or Python need not be compiled.
(iii) A scripting language requires an interpreter while a programming language requires a compiler.
36.
The row heading is get sorted, to avoid the first row should be skipped. This is can be done by using the command "next( )".
37.
The default is reading in text mode. In this mode, while reading from the file the data would be in the format of strings.
38.
A CSV file is a human readable text file where each line has a number of fields, separated by commas or some other delimiter.
39.
(i) We can import the definitions inside a module to another module. We use the import keyword to do this.
(ii) Using the module name we can access the functions defined inside the module. The dot (.) operator is used to access the functions. The syntax for accessing the functions from the module is
<module name>. <function name>
(iii) Example: >>> factorial.fact(5)
40.
The commonly used interfaces are
(i) Python-C-API (API-Application Programming Interface for interfacing with C programs)
(ii) Ctypes (for interfacing with c programs)
(iii) SWIG (Simplified Wrapper Interface Generator- Both C and C++)
(iv) Cython (Cython is both a Python-like language for writing C-extensions)
(v) Boost. Python (a framework for interfacing Python and c++)
(vi) MinGW (Minimalist GNU for Windows)
41.
(i) CSV file - data with default delimiter comma (,)
(ii) CSV file - data with Space at the beginning
(ill) CSV file - data with quotes
(iv) CSV file - data with quotes
42.
To create a CSV file in Notepad,
(i) First open a new file using
File ⟶New or ctrl +N.
(ii) Then enter the data separating each value with a comma and each row with a new line.
(iii) For example consider the following details
Topic1, Topic2, Topic3
one, two, three
Example1, Example2, Example3
(iv) Save this content in a file with the extension.csv.
43.
welcome → module name
● → operator name
display() → definition name
44.
| S.No | PYTHON | C++ |
|---|---|---|
| (i) | Python is typically an "interpreted" language | C++ is typically a "compiled" language |
| (il) | Python is a dynamic typed language | C++ is compiled statically typed language |
| (iii) | Data type is not required while declaring variable | Data type is required while declaring variable |
| (iv) | It can act both as scripting and general purpose language | It is a general purpose language |
45.
Program: To read a csv file with comma (,)
#importing csv
import csv
#opening the csv file which is in different location with read mode
with open('c:\\Pyprg\ \sample1.csv', 'r') as F:
#other way to open the file is
f=('C:\\pyprg\\sample1.csv', 'r')
reader = csv.reader(F))
#printing each line of the Data row by row.
print (row)
F. close( )
Output:
['SNO','NAME', 'CITY']
['12101', 'RAM', 'CHENNAI']
['12102', 'LAVANYA' "TIRUCHY']
['12103', 'LAKSHMAN', 'MADURAI']
46.
(i) 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.
For Example:
>>>f = open ("sample.txt") #open file in current directory # f is file object
>>> f = open ('c:\\Pyprg\ch13 sample5.csv') # specifying full path
(ii) The default is reading in text mode. In this mode, while reading from the file the data would be in the format of strings.
(iii) On the other hand, binary mode returns bytes and this is the mode to be used when dealing with non-text files like image or exe files.
47.
commands for wrapping C++ code:
if___name___ =='___main___':
main(sys.argv[ 1:])
_name_ (A Special variable) in Python:
(i) Since there is no main ( ) function in Python, when the command to run a Python program is given to the interpreter, the code that is at level 0 indentation is to be executed.
(ii) However, before doing that, interpreter will define a few special variables. __name___ is one such special variable which by default stores the name of the file. If the source file is executed as the main program, the interpreter sets the ___name___ variable to have a value as "___main___".
(iii) __name__ is a built-in variable which evaluates to the name of the current module. Thus it can be used to check whether the current script is being run on its own.
(iv) For example consider the following:
if ___name___ ==' ___main___':
main (sys.argv[1:])
(v) if the command line Python program itself is going to execute first, then _main_ contains the name of that Python program and the Python special variable _name_ also contain the Python program name.
(vi) If the condition is true it calls the main which is passed with C++ file as argument.
48.
import csv
csv.register_dialect('myDialect', delimiter = '|', quoting=csv.QUOTE_ALL)
with open('c:\\pyprg\\ch13\\ grade.csv', 'w') as csvfile:
fieldnames = ['Name', 'Grade']
writer = csv.DictWriter(csvfile,
fieldnames=fieldnames. dialect ="myDialect")
writer.writeheader()
writer.writerows([{'Grade': 'B', 'Name': Anu'},
{'Grade': 'A', 'Name': 'Beena',},
{Grade': 'C', 'Name': 'Tarun'}])
print("writing completed")
49.
Import csv
#opening the csv file which is in different location with read mode
f=open("c:\\pyprg\\ch13ample5.csv",'r')
#reading the File with the help of csv.reader( )
readFile=csv.reader(f)
#printing the selected column
for col in readFile:
print col[0],col[3]
f.close ( )
Sample5.csv File in Excel
50.
Execution Steps:
//save above file as welcome.cpp
#Now select File -> New in Notepad and type the Python program
#save the file as fun.py
#Program that compiles and executes a .cpp file
#Python fun.py- iC: |pyprg| welcome - file.cpp
Program:
import sys, os, getopt
def main (argv):
cpp_file="
exe_file="
opts, args = getopt.getopt(argv, "i:", ['ifile='])
for o a in opts
if o in ("-i, "--ifile"):
cpp_file=a+ .'cpp'
exe_file = a+ 'exe'
run (cpp_file, exe_file)
def run (cpp_file, exe_file):
print("Compiling" + Cpp_file)
os.system ('g++' + cpp_file+'_o'+exe_file)
print("Running" + exe_file)
print("---------------")
print
Os.system(exe_file)
print
if_name_=='_main_':
main (sys.argv [1:])
Output:
welcome.
51.
getopt() method returns value consisting of two elements. Each of these values are stored separately in two different list opts and args. opts contains list of splitted strings like made, path and args contains any string if at all not splitted because of wrong path or mode. args will be an empty array if there is no error in splitting strings by getopt().
Example:
The Python code which is going to execute the C++ file p4 in command line will have the getopt() method.
Syntax:
opts, args = getopt.getopt (argv, "i:", ['ifile ='])
where opts contains ('-i','c:\\pyprg\\p4')]]
-i:- option nothing but mode should be followed by
'c:\\pyprg\\p4' value nothing but the absolute path of C++ file,
Since the entire command-line commands are parsed and no leftover arguments, the second argunent args will be empty[].
52.
53.
(i) Python uses Automatic Garbage Collection whereas C++ does not.
(ii) C++ is a statically typed language, while Python is a dynamically typed language.
(iii) Python runs through an interpreter, while C++ is pre-compiled.
(iv) Python code tends to be 5 to 10 times shorter than that written in C++.
(v) In Python, there is no need to declare types explicitly where as it should be done in C++.
(vi) In Python, a function may accept an argument of any type, and return multiple values without any kind of declaration beforehand. Whereas in C++ return statement can return only one value.
54.
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.
For example:↲
xxx,yyy↲
↲denotes enter Key to be pressed
(ii) The last record in the file mayor may not have an ending line break.
For example:
ppp, qqq↲
yyy, xxx
(iii) There may be an optional header line appearing as the first line of the file with the same format as normal record lines. 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.
For example:
field_name 1, field_name 2, field_name 3↲
aaa,bbb,ccc↲
zzz, yyy, xxx CRLF(Carriage Return and Line Feed)
(iv) Within the header and each 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 mayor may not be enclosed in double quotes. If fields are not enclosed with double quotes, then double quotes may not appear inside the fields
For example:
"Red","Blue","Green"↲
Black, White, Yellow
(vi) Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.
For example:
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.
For example:
"Red, " "Blue", "Green",
White
55.
1. CSV file - data with default delimiter comma(,)
2. CSV file - data with space at the beginning.
3. CSV file - data with quotes
4. CSV file - data with custom Delimiters
1. CSV file - data with default delimiter comma(,):
The following program read a file called "Sample1.csv" with default delimiter comma (,) and print row by row.
Program:
#importing csv
import csv
#opening the csv file which is in different location with read mode
with opent('c.\\pyprg\\sample1.csv', 'r') as F:
#other way to open the file is f= ('C:\\pyprg\\ sample1.csv', 'r')
reader = csv.reader(F)
# printing each line of the Data row by row
print(row)
F.close()
Output:
['SNO', 'NAME', 'CITY']
['12101', 'RAM', 'CHENNAI']
['12102', 'LAVANYA', 'TIRUCHY']
['12103', 'LAKSHMAN', 'MADURAI']
2. CSV files - data with spaces at the beginning:
Consider the following file "Sample2.csv containing the following data when opened through notepad.
| Topic 1 | Topic 2 | Topic 3 |
| One, | two, | three, |
| Example 1, | Example 2, | Example 3, |
Program:
import csv
csv.register_dialect ['my Dialect', delimiters=', 'Skipinitialspace= True).
F = open ('c:\\Pyprgl\sample2.csv', 'r')
reader = CSV.reader (F, dialect = 'myDialect')
for row in reader:
print (row)
F.close()
Output:
['Topic 1', 'Topic 2', 'Topic 3']
['One', 'two', 'three']
['Example 1', 'Example 2', 'Example 3']
We can see in "Sample 2.csv" there are spaces after the delimiter due to which the output is also displayed with spaces.
These whitespaces can be removed, by registering new dialects using csv. register _dialect( ) class of csv module. A dialect describes the format of the csv file that is to be read. In dialects the Parameter "skipinitialspace" is used for removing whitespaces after the delimiter.
3. CSV File - Data with Quotes:
We can read the csv files with quotes, by registering new dialects using csv. register_dialect( ) class of csv module.
SNO, Quotes
1, "The Secret to getting ahead is getting started".
2, "Excellence is a continuous process and not an accident."
3, "Work hard dream big never give up and believe Yourself"
4, "Failure is the opportunity to begin again more intelligently".
5, "The successful warrior is the average man, with laser-like focus."
Program:
import cSv
csv.register_ dialect ('MyDialect', delimiter =, 'quoting = csv.QUOTE_ALL, skipinitialspace = True)
f=open ('c:\\Pyprg\\ quotes.csv', 'r')
reader = csv.reader (f, dialect = 'myDialect')
for row in reader:
print (row)
Output:
['SNO, 'Quotes']
['1', 'The secret to getting ahead is getting started'.]
['2', 'Excellence is a continuous process and not an accident'.]
['3', 'Work hard dream big never give up and believe yourself'.]
['4', 'Failure is the opportunity to begin again more intelligently':]
['5', 'The successful warrior is the average man with laser- like focus':]
4. CSV files with custom Delimiters:
We can read csv file having custom the delimiter by registering a new dialect with the help of csv.register_dialect( ).
In the following file called "sample4.csv", each column is separated with |(Pipe Symbol)
| Roll No | Name | City |
| 12101 | Arun | Chennai |
| 12102 | Meena | Kovai |
| 12103 | Ram | Nellai |
| 103 | Ayush | M |
| 104 | Abinandh | M |
Program:
import csv
Csv. register_dialect('myDialect', delimiter= '|')
with open (c:\\pyprg\sample 4.csv', 'r') as f:
reader = csv.reader (f, dialect = "my dialect")
for row is reader:
print (row)
f.close()
Output:
['Roll no', 'Name', 'City]
['12101', 'Arun', 'Chennai']
['12102', 'Meena', 'Kovai']
['12103', 'Ram', 'Nellai']
56.
| Excel | CSV |
|---|---|
| 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, Open Office, 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 |
12th Standard Syllabus & Materials
12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set B
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set A
NEW12th Standard
TN 12th Standard Physics Wave Optics Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Physics Wave Optics Creative Questions Study Material - QB365 Set C
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards