computer public
computer public
com
www.Padasalai.Net www.Trb Tnpsc.com
12th
STD
PUBLIC EXAMINATION - MARCH 2024
PART - III
Reg. No.
Time Allowed : 3.00 Hours] COMPUTER SCIENCE (with Answers) [M aximum Marks : 70
m
Instructions :
1) Check the question paper for fairness of printing. If there is any lack of fairness, inform the Hall
Supervisor immediately.
2) Use Blue or Black ink to write and underline and pencil to draw diagrams
o
PART - I 11. A CSV file is also known as a ________.
.ect
(a) String File (b) Flat File
Note : (i) Answer all the questions. (15×1=15) (c) Random File (d) 3D File
(ii) Choose the most appropriate answer from 12. The most commonly used statement in SQL is :
the given four alternatives and write the (a) execute (b) cursor
.sN
option code and the corresponding answer. (c) commit (d) select
1. Which of the following is used to describe the 13. What is the output of the following snippet in
worst case of an algorithm? Python?
(a) Big W (b) Big A (c) Big O (d) Big S for x in range (5):
aki
2. The datatype whose representation is unknown are if x == 2 :
calles as : continue
print(x, end=' ')
aol
(a) Concrete datatype
(c) Abstract datatype
(b) Built-in datatype
(d) Derived datatype (a) 0 1 3 4
(c) 0 1 2 3 4
(b) 0 1 2
(d) 0 1 2 3
aso
3. Which key is pressed to execute Python Script? 14. ________ is a collection of resources assembled to
(a) F1 (b) F5 (c) F3 (d) F2 create a single unified visual display.
aad b
4. Which of the following defines what an object can (a) Objects (b) Interface
do? (c) Graphics (d) Dashboard
(a) Interface (b) Operating System 15. The clause used to sort data in a database :
(c) Interpreter (d) Compiler (a) GROUP BY (b) SORT BY
5. Which of the following security technique that (c) SELECT (d) ORDER BY
.P r
6. Which of the following is the Slicing Operator? 17. What are the different operators that can be used
(a) < > (b) { } (c) ( ) (d) [ ] in Python?
7. In Python the process of creating an object is called 18. What is searching? Write its types.
as __________. 19. Write the differnt types of function.
w
(a) Initialize (b) Constructor 20. List the types of visualizations in Matplotlib.
(c) Instantiation (d) Destructor 21. What is the difference between Hierarchical and
8. Pick the correct one to execute the given statement Network data model?
w
w
2 Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers
28. Using if..else..elif statement write a suitable 18. A searching algorithm is the step-by-step
program to display largest of 3 numbers. procedure used to locate specific data among a
29. Write a short note for the followings with suitable collection of data. There are two type of searching
example. (a) capitalize( ) (b) swapcase( ) are (i) Linear Search (ii) Binary Search
30. How will you define Construtor and Destructor in 19. Types of Function:
Python? (i) User - defined functions.
31. What are the applications of scripting language?
m
(ii) Built in functions. (iii) Lambda functions.
32. What is the use of Where clause? Give a Python (iv) Recursion functions.
statement by using Where clause.
20. There are many types of Visualizations under
33. Write short notes on TCL Commands in SQL. Matplotlib. Some of them are :
o
PART - IV (i) Line plot (ii) Scatter plot
Note : Answer all the questions: 5 × 5 = 25 (iii) Histogram (iv) Box plot
.ect
34. (a) How will you facilitate data abstraction? (v) Bar chart and (vi) Pie chart
Explain it with suitable example. (OR) 21.
(b) What is Binary Search? Explain it with
example. Hierarchical data model Network data model
.sN
35. (a) Explain input( ) and print( ) functions with In Hierarchical model, a In a Network model,
examples. (OR) child record has only one a child may have
(b) Explain the scope of variables with an example. parent node many parent nodes.
36. (a) What is purpose of range( ) function? Explain
aki
It Hierarchical model, It represents the
with an example. (OR) data is represented as a data in many-to-
(b) Explain the following operators in Relational simple tree like structure many relationships.
algebra with suitable examples.
(i) UNION
aol (ii) INTERSECTION
form.
22. (i) A CSV file is a human readable text file where
aso
(iii) DIFFERENCE
(iv) CARTESIAN PRODUCT each line has a number of fields, separated by
commas or some other delimiter.
37. (a) What are the components of SQL? Write the
aad b
commands for each. (OR) (ii) A CSV file is also known as a Flat File.
(b) Discuss the features of Python over C++. 23. The fetchall() method is used to fetch all rows from
38. (a) Write the different methods to read a file in the database table. Eg : result = cursor.fetchall()
Python. (OR) 24. pop( ) function can also be used to delete an
(b) Explain the various buttons in a matplotlib element using the given index value. pop( )
.P r
PART - III
PART - I 25.
1. (c) Big O 2. (c) Abstract datatype S. No. Pure Impure
ww.s
(ii) The definition of ADT only mentions what ways. The first way is via our familiar method
operations are to be performed but not how of multiple assignment, which unpacks a list
these operations will be implemented. into its elements and binds each element to a
17. (i) In computer programming languages different name.
operators are special symbols which represent lst := [10, 20]
computations, conditional matching etc. x, y := lst
(ii) Operators are categorized as Arithmetic, (ii) In the above example x will become10 and y
Relational, Logical, Assignment etc. will become 20.
Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers 3
m
lst[0] General format of constructor :
10 General format of _ _init_ _ method
lst[1] (Constructor function)
20 def _ _init_ _(self, [args ……..]):
o
27. Asymptotic Notations are languages that uses <statements>
meaningful statements about time and space Destructor :
.ect
complexity. The following three asymptotic (i) Destructor is also a special method to destroy
notations are mostly used to represent time the objects.
complexity of algorithms: (ii) In Python, _ _del_ _( ) method is used as
.sN
(i) Big O : Big O is often used to describe the destructor. It is just opposite to constructor.
worst-case of an algorithm. 31. Applications of Scripting Languages :
(ii) Big Ω : Big Omega is the reverse Big O, if Bi 1. To automate certain tasks in a program
O is used to describe the upper bound (worst 2. Extracting information from a data set
aki
- case) of a asymptotic function, Big Omega is 3. Less code intensive as compared to traditional
used to describe the lower bound (best-case). programming language
(iii) Big Θ : When an algorithm has a complexity 4. can bring new functions to applications and
with lower bound = upper bound, say that an
aol glue complex systems together
algorithm has a complexity O (n log n) and Ω 32. The WHERE clause is used to extract only those
aso
(n log n), it’s actually has the complexity Θ (n records that fulfill a specified condition.
log n), which means the running time of that Example : To display the different grades scored
algorithm always falls in n log n in the best- by male students from "student table"
aad b
biggest=n3 ('C',)
print("The biggest number ('D',)
between",n1,",",n2,"and",n3,"is",biggest) 33. (i) Commit : Saves any transaction into the
Output : database permanently.
w
Enter the first number:1 (ii) Roll back : Restores the database to last
Enter the second number:3 commit state.
Enter the third number:5 (iii) Save point : Temporarily save a transaction
w
4 Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers
(iii) For example, say you have an abstract data (iii) First, we find index of middle element of the
type called city. array by using this formula :
(iv) To create a city object, you'd use a function mid = low + (high - low) / 2
like city = makecity (name, lat, lon). (iv) Here it is, 0 + (9 - 0 ) / 2 = 4 (fractional part
(v) Here makecity (name, lat, lon) is the ignored). So, 4 is the mid value of the array.
constructor which creates the object city.
m
(name, lat, lon) value passed as parameter
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
make city ( )
(v) Now compare the search element with the
o
value stored at mid value location 4. The value
city stored at location or index 4 is 50, which is
not match with search element. As the search
.ect
lat lon
value 60 is greater than 50.
Constructor 10 20 30 40 50 60 70 80 90 99
Selectors :
.sN
0 1 2 3 4 5 6 7 8 9
(i) Selectors are functions that retrieve (vi) Now we change our low to mid + 1 and find
information from the data type. the new mid value again using the formula.
(ii) Selectors extract individual pieces of low = mid + 1
information from the object.
aki
mid = low + (high - low) / 2
(iii) To extract the information of a city object, (vii) Our new mid is 7 now. We compare the value
you would used functions like stored at location 7 with our target value 60.
getname(city),
getlat(city),
getlon(city)
aol 10 20 30 40 50 60 70 80 90 99
aso
These are the selectors because these 0 1 2 3 4 5 6 7 8 9
functions extract the information of the city
object. (viii) The value stored at location or index 7 is not
aad b
city value passed as parameter city value passed as parameter city value passed as parameter
a match with search element, rather it is more
than what we are looking for. So, the search
element must be in the lower part from the
getname ( ) getlat ( ) getlon ( ) current mid value location
10 20 30 40 50 60 70 80 90 99
.P r
(OR) 0 1 2 3 4 5 6 7 8 9
u
(b) B
inary search : Binary search also called half- (ix) The search element still not found. Hence,
interval search algorithm. It finds the position of a we calculated the mid again by using the
search element within a sorted array. formula.
ww.s
matched. 10 20 30 40 50 60 70 80 90 99
(3) If no match is found for all comparisons,
0 1 2 3 4 5 6 7 8 9
then display unsuccessful message.
(x) Now we compare the value stored at location
w
(i) List of elements in an array must be sorted 5 with our search element. We found that it is
first for Binary search. The following example a match.
describes the step by step operation of binary 10 20 30 40 50 60 70 80 90 99
search.
w
0 1 2 3 4 5 6 7 8 9
(ii) Consider the following array of elements, (xi) We can conclude that the search element 60
the array is being sorted so it enables to do is found at location or index 5. For example
the binary search algorithm. Let us assume if we take the search element as 95, For this
that the search element is 60 and we need to value this binary search algorithm return
search the location or index of search element unsuccessful result.
60 using binary search.
35. (a) Input and Output Functions : A program
10 20 30 40 50 60 70 80 90 99 needs to interact with the user to accomplish
0 1 2 3 4 5 6 7 8 9 the desired task; this can be achieved using
kindly send me your key Answers to our email id - [email protected]
[email protected] Ph: 8124201000 / 8124301000
www.surabooks.com
www.Padasalai.Net www.Trb Tnpsc.com
Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers 5
m
(i) In Python, input( ) function is used to accept
data as input at run time. The syntax for (iii) Example :
input() function is, >>> print (“Welcome to Python
Variable = input (“prompt string”) Programming”)
(ii) Where, prompt string in the syntax is a Welcome to Python Programming
o
statement or message to the user, to know >>> x = 5
what input can be given. >>> y = 6
.ect
(iii) If a prompt string is used, it is displayed on >>> z = x + y
the monitor; the user can provide expected >>> print (z)
data from the input device. The input( ) takes 11
.sN
whatever is typed from the keyboard and >>> print (“The sum = ”, z)
stores the entered data in the given variable. The sum = 11
(iv) If prompt string is not given in input( ) no >>> print (“The sum of ”, x, “ and ”, y, “ is ”, )z
message is displayed on the screen, thus, the The sum of 5 and 6 is 11
(iv) The print ( ) evaluates the expression before
aki
user will not know what is to be typed as
input. printing it on the monitor.
(v) Example 1 : input( ) with prompt string (v) The print () displays an entire statement
>>> city=input (“Enter Your City: ”) which is specified within print ( ). Comma (,)
aol
Enter Your City: Madurai
>>> print (“I am from “, city)
is used as a separator in print ( ) to print more
than one item.
aso
I am from Madurai (OR)
(vi) Example 2 : input( ) without prompt string (b) Scope of variable refers to the part of the program,
aad b
more interactive, provide prompt string with the variable becomes local to it.
input( ). (iii) A local variable only exists while the function
is executing.
(viii)The input ( ) accepts all data as string but (iv) The formal parameters are also local to
not as numbers. If a numerical value is
w
function.
entered, the input values should be explicitly (v) Example: Create a Local Variable
converted into numeric data type. The def loc():
int( ) function is used to convert string data y=0 # local scope
w
print(y)
(ix) Example 3 : loc()
x = int (input(“Enter Number 1: ”)) Output:
y = int (input(“Enter Number 2: ”)) 0
w
print (“The sum = ”, x+y) Global Scope : A variable, with global scope can
Output : be used anywhere in the program. It can be created
Enter Number 1: 34 by defining a variable outside the scope of any
Enter Number 2: 56 function.
The sum = 90 Rules of global Keyword :
The print() function : The basic rules for global keyword in Python are:
(i) In Python, the print() function is used to (i) When we define a variable outside a function,
display result on the screen. The syntax for it’s global by default. You don’t have to use
print() is as follows : global keyword.
kindly send me your key Answers to our email id - [email protected]
[email protected] Ph: 8124201000 / 8124301000
www.surabooks.com
www.Padasalai.Net www.Trb Tnpsc.com
6 Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers
(ii) We use global keyword to modify the value of example explains how to create a list with
the global variable inside a function. squares of first 10 natural numbers.
(iii) Use of global keyword outside a function has Example : Generating squares of first 10
no effect. natural numbers
Example : Accessing global Variable From squares = [ ]
Inside a Function for x in range(1,11):
c=1 # global variable s = x ** 2
m
def add(): squares.append(s)
print(c) print (squares)
add() Output : [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Output: (OR)
o
1 (b) (i) UNION (Symbol : ∪) :
36. (a) The range( ) is a function used to generate (i) It includes all tuples that are in tables A or in
.ect
a series of values in Python. Using range B. It also eliminates duplicates. Set A Union
( ) function, you can create list with series Set B would be expressed as A ∪ B
of values. The range( ) function has three (ii) Example
.sN
arguments. Consider the following tables
Syntax of range ( ) function: Table A Table B
range (start value, end value, step value) Stud no Name Stud no Name
where, cs1 Kannan cs1 Kannan
aki
(i) start value – beginning value of series. Zero
is the default beginning value. cs2 Lenin cs2 GowriShakaran
(ii) end value – upper limit of series. Python cs3 Padmaja cs3 Lenin
aol
takes the ending value as upper limit – 1.
(iii) step value – It is an optional argument,
Result :
Stud no
Table A ∪ B
Name
aso
which is used to generate different interval of
values. cs1 Kannan
Example: Generating whole numbers upto 10 cs2 GowriShankaran
aad b
3
4 and B must be union-compatible.
u
8 cs1 Kannan
9 cs3 Lenin
10
(iii) SET DIFFERENCE ( Symbol : –) :
Creating a list with series of values :
w
Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers 7
(iii) This type of operation is helpful to merge (ii) SQL commands which come under Data
columns from two relations. Control Language are :
Table A Table B Table A × Table B
1 S 1 S Grant Grants permission to one or more
1 R
users to perform specific tasks.
2
R
2 S
Revoke Withdraws the access permission
3
given by the GRANT statement.
m
2 R
Table A = 3
Table B = 2
ransactional Control Language :
T
3 S
Table A × B = 3 × 2 = 6 (i) Transactional control language (TCL)
3 R
commands are used to manage transactions
o
Cartesian Product
in the database.
37. (a) Components of SQL : SQL commands are
(ii) SQL command which come under Transfer
divided into five categories:
.ect
Control Language are :
DDL - Data Definition Language
Commit Saves any transaction into the
DML - Data Manipulation Language
database permanently.
.sN
DCL - Data Control Language Roll back Restores the database to last
TCL - Transaction Control Language
commit state.
Save Temporarily save a transaction so
DQL - Data Query Language
point that you can rollback.
aki
Data Definition Language : Data Query Language :
(i) The Data Definition Language (DDL) consist (i) The Data Query Language consist of
of SQL statements used to define the database
aol
structure or schema.
(ii) It simply deals with descriptions of the
commands used to query or retrieve data
from a database.
aso
database schema and is used to create and (ii) One such SQL command in Data Query
modify the structure of database objects in Language is
aad b
removing (deleting), and modifying (vi) In Python, a function may accept an argument
(updating) data in a database. of any type, and return multiple values
(ii) SQL commands which comes under Data without any kind of declaration beforehand.
w
Delete Deletes all records from a table, but (i) Use the csv module’s reader function
not the space occupied by them. (ii) Use the DictReader class.
Data Control Language : Two ways of Reading CSV File
A Data Control Language (DCL) is a
(i)
programming language used to control the
access of data stored in a database. It is used
for controlling privileges in the database reader () function Dict Reader class
(Authorization).
kindly send me your key Answers to our email id - [email protected]
[email protected] Ph: 8124201000 / 8124301000
www.surabooks.com
www.Padasalai.Net www.Trb Tnpsc.com
8 Sura’s 12th Std - Computer Science Public Examination - March 2024 Question Paper with Answers
CSV Module’s Reader Function : (iv) The main difference between the csv.reader()
(i) You can read the contents of CSV file with and DictReader() is in simple terms csv.
the help of csv.reader() function. The reader reader and csv.writer work with list/tuple,
function is designed to take each line of the while csv.DictReader and csv.DictWriter
file and make a list of all columns. work with dictionary. csv.DictReader and
(ii) Using this function one can read data from csv.DictWriter take additional argument
m
csv files of different formats like quotes (" "), fieldnames that are used as dictionary keys.
pipe (|) and comma (,). For Example Reading “sample8.csv” file into
The syntax for csv.reader() is a dictionary
csv.reader(fileobject,delimiter,fmtparams) import csv
o
where filename = ‘c:\pyprg\sample8.csv’
(iii) file object : passes the path and the mode of input_file =csv.
the file DictReader(open(filename,’r’))
.ect
(iv) delimiter: an optional parameter containing for row in input_file:
the standard dilects like , | etc can be omitted. print(dict(row)) #dict() to print data
(v) fmtparams : optional parameter which help Output :
.sN
to override the default values of the dialects {‘ItemName ‘: ‘Keyboard ‘, ‘Quantity’: ‘48’}
like skipinitialspace,quoting etc. can be {‘ItemName ‘: ‘Monitor’, ‘Quantity’: ‘52’}
omitted. {‘ItemName ‘: ‘Mouse ‘, ‘Quantity’: ‘20’}
Program : (OR)
aki
#importing csv
Buttons in the output : In the output figure, you
(b)
import csv can see few buttons at the bottom left corner. Let
#opening the csv file which is in different location
aol
with read mode
with open('c:\pyprg\sample1.csv', 'r',
us see the use of these buttons.
aso
Subplots
newline‘=’) as F: Home Button Pan Axis Button Button
#other way to open the file is f= ('c:\\pyprg\\
aad b
sample1.csv', 'r')
reader = csv.reader(F)
# printing each line of the Data row by row Forward / Back Buttons Zoom
Button
Save the
Figure Button
for row in order
print(row) (i) Home Button → The Home Button will help
once you have begun navigating the chart. If
.P r
F.close()
you ever want to return back to the original
Output : view, you can click on this.
u
done by using DictReader method of csv you to click it, and then click and drag graph
module which works similar to the reader() around.
class but creates an object which maps data (iv) Zoom → The Zoom button lets you click on it,
then click and drag a square that you would
w
to a dictionary.
w
(ii) The keys are given by the fieldnames as like to zoom into specifically. Zooming in
parameter. DictReader works by reading the will require a left click and drag. Zoom out
first line of the CSV and using each comma with a right click and drag.
(v) Configure Subplots → This button allows
w