12 CS Quarterly EM 2024 Answer Key
12 CS Quarterly EM 2024 Answer Key
ANSWER KEY
PART – I
Choose the most appropriate answer from the given four alternatives and write the
option code and the corresponding answer. 15 × 1 = 15
Q. No Answer Mark
1 (A) Arguments 1
2 (D) Abstract datatype 1
3 (B) Protected members 1
4 (C) = 1
5 Mere Attempt 1
6 (A) >>> 1
7 (A) # 1
8 (A) for 1
9 (C) 2 4 6 8 1
10 (A) Lambda 1
11 (D) def 1
12 (A) + 1
13 (C) Immutable 1
14 (B) 8 1
15 (D) Instantiation 1
Part – II
Answer any SIX of the following: 6 × 2 = 12
Question number 24 is compulsory.
Q. No Answer Marks
Abstract Data type (ADT) is a type (or class) for objects whose
16 2
behaviour is defined by a set of value and a set of operations.
Namespaces are containers for mapping names of variables to
17 2
objects.
Finding a particular element (value) from a set is called as 1
18 searching.
Types of searching: (1) Linear Search (2) Binary Search 1
1
Q. No Answer Marks
19 The value of m = 20 2
The range( ) generates a list of values starting from start till stop-1. 1
20 Syntax:
range (start, stop, [step]) 1
21 Mere attempt 2
22 EMISEMISEMIS 2
24 4 5.6…… 1 False 2
Part - III
Answer any SIX of the following: 6 × 3 = 18
Question number 33 is compulsory.
Q. No Answer Marks
Pure Function Impure Function
25 The return value of the pure The return value of the 3
functions solely depends on its impure functions does not
arguments passed. solely depend on its
arguments passed.
if you call the pure functions with if you call the impure
the same set of arguments, you functions with the same set of
will always get the same return arguments, you might get the
values. different return values
They do not have any side They have side effects
effects.
They do not modify the They may modify the
arguments which are passed to arguments which are passed
them to them
(Any Three differences)
• Local scope refers to variables defined in current function. 1
26
• Always, a function will first look up for a variable name in its
1
local scope.
• Suitable Example 1
27 • The complexity of an algorithm f (n) gives the running time
and/or the storage space required by the algorithm in terms of 1
n as the size of input data.
• Time Complexity:
o The Time complexity of an algorithm is given by the 1
number of steps taken by the algorithm to complete the
process.
2
• Space Complexity: 1
o Space complexity of an algorithm is the amount of
memory required to run to its completion.
28 • Ternary operator is also known as conditional operator that
evaluates something based on a condition being true or false. 1
• Syntax:
Variable Name = [on_true] if [Test expression] else [on_false] 1
• Suitable Example 1
29 10 11 12 13 14 15
Value of x when the loop exit 16 3
30 ceil( ) floor( )
Returns the smallest integer Returns the largest integer less
greater than or equal to the than or equal to the given value. 1
given number
Part – IV
Answer all questions: 5 × 5 = 25
Q. No Answer Marks
34 (a) Parameters are the variables in a function definition and arguments are
the values which are passed to a function definition. 1
Example:
let rec pow a b:= 1½
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 example with proper explanation
3
Example:
let rec pow (a: int) (b: int) : int := 1½
if b=0 then 1
else a * pow b (a-1)
• 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 example with proper explanation
34 (b) To facilitate data abstraction, you will need to create two types of
functions: 2
(i) Constructors (ii) Selectors.
(i) Constructors:
• Constructors are functions that build the abstract data type. 1½
• Example:
city:= makecity (name, lat, lon)
Here makecity (name, lat, lon) is the constructor
which creates the object city.
(ii) Selectors:
• Selectors are functions that retrieve information from the data 1½
type.
• Example:
getname(city)
getlat(city)
getlon(city)
(OR) Any suitable example for constructor & Selector
35 (a) (1) Modules contain instructions, processing logic, and data.
(2) Modules can be separately compiled and stored in a library. 1
(3) Modules can be included in a program. Each
(4) Module segments can be used by invoking a name and some
parameters.
(5) Module segments can be used by other modules.
35 (b) • Bubble sort is a simple sorting algorithm.
• The algorithm starts at the beginning of the list of values stored 2
in an array.
• It compares each pair of adjacent elements and swaps them if
they are in the unsorted order.
• Procedure
1. Start with the first element i.e., index = 0, compare 3
the current element with the next element of the array.
4
Q. No Answer Marks
• The syntax:
Variable = input (“prompt string”)
½
• Suitable Example
1
(2) The print() function
• In Python, the print() function is used to display result on the
screen.
1
• The syntax:
print(“string to be displayed as output ”)
print(variable) ½
• Suitable Example
1
36 (b) (a) id( ) 1
• Returns the “identity of an object” ie. the memory address of the
object.
• Suitable Example
(b) chr( ) 1
• Returns the Unicode character for the given ASCII value.
• Suitable Example
(c) round( )
• Returns the nearest integer to its input.
1
• General format:
round(number [,ndigits])
• Suitable Example
(d) type( )
• Returns the type of an object for the given single object.
• Suitable Example 1
(e) pow( )
• Returns the computation of a raised to the power of b.
• Suitable Example 1
37 (a) Suitable Python program using if…elif…else 5
5
(ii) Append (+ =) 1
• Adding more strings at the end of an existing string is known as
append.
• The operator += is used to append a new string with an existing
string.
• Suitable Example
(ii) Intersection:
• It includes the common elements in two sets 1
• Operator used: &
• Function used: intersection( )
• Suitable Example.
(iii) Difference:
• It includes all elements that are in first set (set A) but not in the
1½
second set (set B)
• Operator used: - (minus)
• Function used: difference( )
• Suitable Example.
K. KANNAN,
Chennai Girls’ Hr. Sec. School,
Rotler Street, Chennai – 600112.
-o O o-