Computer Science em
Computer Science em
Maximum Marks: 70
Note:
1. Only answers written in Blue Or Black ink should be evaluated
2. Choose the most appropriate answer the given four alternatives and
write the option code and the corresponding answer.
PART – I
Option
Q.No. Answer Mark
Code
1 (c) Definition 1
2 (a) Constructor 1
3 (b) LEGB 1
4 (c) Half-interval search 1
5 (b) Ternary 1
6 (a) for 1
7 (d) return 1
8 (a) positive or negative numbers 1
9 (a) ecneicS retupmoC 1
10 (d) . 1
11 (b) Chen 1
12 (b) SELECT 1
13 (a) Modification 1
14 (b) OS module 1
15 (b) Distinct 1
Page | 1
Part – II
Answer Any Six questions Question No.24 is compulsory. 6×2=12
Q.No Answer Marks
16 Any way of bundling two values together into one can be 1
considered as a pair.
Eg : Lists (or ) Any Suitable Example. 1
18 Output :
5 10 15 2
24 OUTPUT
False 1
welcome 1
Page | 2
Part – III
Answer Any SIX questions Question No.33 is compulsory. 6×3=18
Q.No Answer Marks
25 The variables used inside the function may cause side
effects though the functions which are not passed with any
arguments. In such cases the function is called impure
function. When a function depends on variables or functions 3
outside of its definition block, you can never be sure that
the function will behave the same every time it’s called.
Example: random( ) function.
26 Global Variable:
(i). A variable which is declared outside of all the
functions in a program.
(ii). Global Variable can be accessed inside or outside of 3
all the functions in a program.
(Give Suitable Example)
27 Assignment Operator
=
+=
-=
*= 3
/=
%=
**=
//=
28 Ceil ( ) Floor ( )
29 (i). List.remove(element). 1
(ii). List.pop(index of an element) (or) List.pop() 1
(iii). List.clear(). 1
Page | 3
30 Cross product is a way of combining two relations. The
resulting relation contains, both relations being 3
combined.
(Any Suitable Example)
31 reader work with list/tuple.
DictReader() work with dictionary 3
32 fetchone()
The fetchone() method returns the next row of a query
result set
None in case there is no row left.
fetchmany() 3
Displaying specified number of records is done by using
fetchmany().
This method returns the number of rows of the result
set.
33 OUTPUT :
[1,4,9,16,25] 3
Part – IV
Answer all of the following Questions 5×5=25
Q.
Answer Marks
No
34 Pure Function Impure Function
a)
The return value of the The return value of the
pure functions solely impure functions does not
depends on its arguments solely depend on its
passed. arguments passed.
If you call the pure If you call the impure
functions with the same functions with the same 5
set of arguments, you will set of arguments, you
always get the same might get the different
return values. return values
They do not have any side They do have any side
effects. effects
This function do not This function may modify
modify the arguments the arguments
2
Explanation
1
Any Suitable Example
(OR)
(b) Python File Modes
‘r’ - Open a file for reading. (default)
‘w’ - Open a file for writing. Creates a new file if it does not
exist or truncates the file if it exists.
‘x’ - Open a file for exclusive creation. If the file already
exists, the operation fails. 5
‘a’ - Open for appending at the end of the file without
truncating it. Creates a new file if it does not exist.
‘t’ - Open in text mode. (default)
‘b’ - Open in binary mode.
‘+’ - Open a file for updating
Page | 5
37 Functions that calls itself is known as recursive. Recursion works 2
(a) like loop but sometimes it makes more sense to use recursion than
loop.
Overview of how recursive function works:
Recursive function is called by some external code.
If the base condition is met then the program gives
2
meaningful output and exits.
Otherwise, function does some required processing and then
calls itself to continue recursion.
Any Suitable Example
1
(OR)
(b) sys Module:
This Module provides access to built-in varibales used by the
interpretor
sys.argv is the list of command-line arguments passed to the
Python program.
The first argument, sys.argv[0] contains the name of the
python
Program
sys.argv [1]is the next argument passed to the program (here
it
is the C++ file), which will be the argument passed through
main ().
os Module :
The os module in Python provides a way of using operating
system dependent functionality. 5
The functions that the os module allows you to interface with
the Windows operating system.
getopt module :
The getopt module of Python helps you to parse (split)
command-line options and arguments.
This module provides getopt() method to enable command-
line
argument parsing.
Syntax :
<opts>,<args>=getopt.getopt(argv, options, [long_options])
Page | 6
38 Output
(a) {1, 2, 3, 4, 5, 6, 7, 8} 1
{4, 5} 1
{1, 2, 3} 1
{6, 7, 8} 1
{1,2,3,6,7,8} 1
(OR)
(b) Aggregate Function :
Page | 7