12-CS-Halfyearly-EM-2024-Answer Key
12-CS-Halfyearly-EM-2024-Answer Key
QN Answer Mark
1 (D) Parameters 1
2 (A) Pair 1
3 (C) = 1
9 (D) [0, 1, 8] 1
10 (C) class class_name: 1
11 (C) Hierarchical 1
12 (A) DROP 1
13 (D) Carriage Return and Line Feed 1
14 (A) OS module 1
15 (A) Distinct 1
PART – II
Answer any SIX of the following: 6 × 2 = 12
Question number 24 is compulsory.
QN Answer Mark
Constructor Selectors
Constructors are functions that Selectors are functions that
16 2
build the abstract data type. retrieve information from the
data type.
1
QN Answer Mark
if <condition>:
statements-block 1
18 2
else:
statements-block 2
19 ComputerComputerComputer 2
20 11 2
24 {'A', 'D'} 2
PART – III
Answer any SIX of the following: 6 × 3 = 18
Question number 33 is compulsory.
QN Answer Mark
The strlen is a pure function because the function takes one variable as a 1½
parameter, and accesses it to find its length.
This function reads external memory but does not change it, and the value 1½
25
returned derives from the external memory accessed.
(OR)
strlen is a pure function because it does not modify the input string, has no side 3
effects, and returns the same result for the same input
2
QN Answer Mark
reader( ) DictReader( )
Reads CSV files into a list. Reads CSV files into a dictionary.
csv.reader works with list/tuple. csv.DictReader works with 3
31 dictionary.
Takes each line of the file and Takes additional argument
make a list of all columns. fieldnames that are used as
dictionary keys.
SQLite is a simple relational database system, which saves its data in regular
data files or even in the internal memory of the computer. 1
Advantages:
32
1. It is designed to be embedded in applications, instead of using a
separate database server program such as MySQLor Oracle. 2
2. SQLite is fast, rigorously tested, and flexible, making it easier to work.
Python has a native library for SQLite.
33 {0: 0, 1: 1, 2: 4, 3: 9, 4: 16} 3
PART – IV
Answer all questions: 5 × 5 = 25
QN Answer Mark
Parameters are the variables in a function definition and arguments are the 1
34 (a) values which are passed to a function definition.
Example:
let rec pow a b:=
if b=0 then 1
else a * pow a (b-1)
In the above function definition variable ‘a’ and ‘b’ are the parameters, the value
which is passed to the variable ‘a’ and ‘b’ are the arguments.
We have not mentioned any data types to the parameters.
(OR Any suitable algorithm with explanation)
When we write the type annotations for ‘a’ and ‘b’ the parentheses are
mandatory.
In the above function definition variable ‘a’ and ‘b’ are having the data type -
integer. Which means, value passed to the parameters should be integers.
(OR Any suitable algorithm with explanation)
3
(i) Local Scope:
34 (b) A variable declared inside the function's body or in the local scope is known as 1
local variable.
Suitable Example:
½
(ii) Global Scope:
Defining a variable outside the scope of any function/block.
Global scope can be used anywhere in the program. 1
Suitable Example ½
(1) Less code to be written.
35 (a) (2) A single procedure can be developed for reuse, eliminating the
need to retype the code many times. 1 Each
(3) Programs can be designed more easily because a small team (5)
deals with only a small part of the entire code.
(4) Modular programming allows many programmers to collaborate on
the same application.
(5) The code is stored across multiple files.
(6) Code is short, simple and easy to understand.
(7) Errors can easily be identified, as they are localized to a subroutine or
function.
(8) The same code can be used in many applications.
(9) The scoping of variables can easily be controlled.
(Any Five points)
(1) SELECT (Symbol: σ)
35 (b) • General form σc ( R ) with a relation R and a condition C on the 1 Each
attributes of R. (5)
• The SELECT operation is used for selecting a subset with tuples
according to a given condition.
• Select filters out all tuples that do not satisfy C.
4
• Set A Union Set B would be expressed as A ∪ B
(4) SET DIFFERENCE (Symbol: - )
• The result of A – B, is a relation which includes all tuples that are in A
but not in B.
• The attribute name of A has to match with the attribute name in B.
(5) INTERSECTION (Symbol: ∩) A ∩ B
• Defines a relation consisting of a set of all tuple that are in both in A
and B.
• However, A and B must be union-compatible.
(6) PRODUCT OR CARTESIAN PRODUCT (Symbol: X )
• Cross product is a way of combining two relations.
• The resulting relation contains, both relations being combined.
• A x B means A times B, where the relation A and B have different
attributes.
• This type of operation is helpful to merge columns from two relations.
37 (a) The for loop is usually known as a definite loop, because the programmer 1
knows exactly how many times the loop will be executed.
5
Syntax:
for counter_variable in sequence: 1
statements-block 1
[else:
statements-block 2]
The for .... in statement is a looping statement used in Python to iterate over a 1
sequence of objects, i.e., it goes through each item in a sequence.
The control variable accesses each item of the sequence on each iteration until 1
it reaches the last item in the sequence.
Suitable Example 1
(i) COUNT()
37 (b) The SQL COUNT() function returns the number of rows in a table satisfying 1 Each
the criteria (5)
specified in the WHERE clause.
Example:
cursor.execute("SELECT COUNT(*) FROM student ")
(OR - Any suitable example)
(ii) AVG()
The SQL AVG() function returns the average of row / column data in a table.
Example:
cursor.execute("SELECT AVG(AVERAGE) FROM student ")
(OR - Any suitable example)
(iii) SUM()
The SQL SUM() function returns the sum of row / column data in a table.
Example:
cursor.execute("SELECT SUM(AVERAGE) FROM student ")
(OR - Any suitable example)
(iv) MAX()
The MAX() function returns the largest value of the selected column.
Example:
cursor.execute("SELECT sname,max(AVERAGE) FROM student ")
(OR - Any suitable example)
(v) MIN()
The MIN() function returns the smallest value of the selected column.
Example:
cursor.execute("SELECT sname,min(AVERAGE) FROM student ")
(OR - Any suitable example)
1. Computer Science
38 (a) 2. Computer 1 Each
3. Science (5)
4. Cmue cec
5. eniSrtpo
1. {1, 2, 3, 4, 5, 6}
38 (b) 2. {2, 3, 4, 5}
1 Each
3. {1}
(5)
4. {6}
5. {1, 6}