CS Board 19to23

Download as pdf or txt
Download as pdf or txt
You are on page 1of 136

SET-4

Series BVM Code No. 91


Candidates must write the Code on the
Roll No.
title page of the answer-book.

 Please check that this question paper contains 27 printed pages.


 Code number given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.
 Please check that this question paper contains 7 questions.
 Please write down the Serial Number of the question before
attempting it.
 15 minute time has been allotted to read this question paper. The question
paper will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the
students will read the question paper only and will not write any answer on the
answer-book during this period.

COMPUTER SCIENCE

Time allowed : 3 hours Maximum Marks : 70

General Instructions :
(i) SECTION A refers to programming language C++.
(ii) SECTION B refers to programming language Python.
(iii) SECTION C is compulsory for all.
(iv) Answer either SECTION A or SECTION B.
(v) It is compulsory to mention on the page 1 in the answer-book whether you
are attempting SECTION A or SECTION B.
(vi) All questions are compulsory within each section.
(vii) Questions 2(b), 2(d), 3 and 4 have internal choices.

91 1 P.T.O.
SECTION A
[Only for candidates, who opted for C++]
1. (a) Write the names of any four fundamental data types of C++. 2
(b) Write the names of the correct header files, which must be included
in the following C++ code to compile the code successfully : 1
void main()
{
char L[]="CS 2018";
int N=strlen(L);
cout<<L[N-1];
}
(c) Rewrite the following C++ program after removing any/all
syntactical error(s). Underline each correction done in the code : 2
Note : Assume all required header files are already included in the
program.
#define Area(L,B) = L*B
structure Recta
{
int Length,Breadth;
};
void main()
{
Recta R = [10,15];
cout<<Area(Length.R,Breadth.R);
}
(d) Find and write the output of the following C++ program code : 2
Note : Assume all required header files are already included in the
program.
void Alter(char *S1, char *S2)
{
char *T;
T=S1;
S1=S2;
S2=T;
cout<<S1<<"&"<<S2<<end1;
}
void main()
{
char X[]="First", Y[]="Second";
Alter(X,Y);
cout<<X<<"*"<<Y<<end1;
}
91 2
(e) Find and write the output of the following C++ program code : 3
Note : Assume all required header files are already included in the
program.

void Convert(float &X, int Y=2)


{
X=X/Y;
Y=X+Y;
cout<<X<<"*"<<Y<<endl;
}
void main()
{
float M=15, N=5;
Convert(M,N);
Convert(N);
Convert(M);
}

(f) Observe the following C++ code and find the possible output(s) from
the options (i) to (iv) following it. Also, write the minimum and
maximum values that can possibly be assigned to the variable End. 2
Note :
 Assume all the required header files are already being included in
the code.
 The function random(N) generates any possible integer between
0 and N-1 (both values included).

void main()
{
randomize();
int A[]={10,20,30,40,50,60,70,80};
int Start = random(2) + 1;
int End = Start + random(4);
for(int I=Start; I<=End, I++)
cout<<A[I]<<"$";
}

(i) 10$20$30$ (ii) 20$30$40$50$60$

(iii) 30$40$50$60$ (iv) 40$50$60$70$


91 3 P.T.O.
2. (a) Given the following class Test and assuming all necessary header
file(s) included, answer the questions that follow the code :
class Test
{
int Marks; char TName[20];
public:
Test(int M) //Function 1
{
Marks = M;
}
Test(char S[]) //Function 2
{
strcpy(TName,S);
}
Test(char S[], int M) //Function 3
{
Marks = M;
strcpy(TName,S);
}
Test(Test &T) //Function 4
{
Marks = T.Marks + 10;
strcpy(TName,T.TName);
}
};

void main()
{
Test T1(10); //Statement I
Test T2(70); //Statement II
Test T3(30, "PRACTICAL"); //Statement III
_______________; //Statement IV
}

(i) Which of the statement(s) out of (I), (II), (III), (IV) is/are
incorrect for object(s) of the class Test ? 1

(ii) What is Function 4 known as ? Write the Statement IV,


that would execute Function 4. 1

91 4
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.

class Point
{
int X,Y;
public:
Point(int I=10, int J=20) //Function 1
{
X = J;
Y = I;
}
void Show() //Function 2
{
cout<< " Points are " << X << " & " << Y <<endl;
}
~Point() //Function 3
{
cout<<"Points Erased"<<endl;
}
};

void main()
{
Point P(5);
P.Show();
}

(i) For the class Point, what is Function 3 known as ? When is


it executed ? 1

(ii) What is the output of the above code, on execution ? 1

OR

(b) Explain Polymorphism in context of Object Oriented Programming.


Also give a supporting example in C++. 2

91 5 P.T.O.
(c) Write the definition of a class GRAPH in C++ with following
description : 4

Private Members

 XUnit // integer

 YUnit // integer

 Type // char array of size 20

 AssignType() /* Member function to assign value of

Type based upon XUnit and YUnit as

follows : */

Condition Type

XUnit = 0 Or YUnit = 0 None

XUnit is more than YUnit Bar

XUnit is less than or equal to YUnit Line

Public Members

 InXY() /* Function to allow user to enter values

of XUnit and YUnit and then invoke

AssignType() to assign value of Type */

 OutXY() // Function to display XUnit, Yunit and Type

91 6
(d) Answer the questions (i) to (iv) based on the following : 4
class Ground
{
int Rooms;
protected:
void Put();
public:
void Get();
};

class Middle : private Ground


{
int Labs;
public:
void Take();
void Give();
};

class Top : public Middle


{
int Roof;
public:
void In();
void Out();
};

void main()
{
Top T;
}
(i) Which type of Inheritance out of the following is illustrated
in the above example ?
 Single Level Inheritance, Multilevel Inheritance,
Multiple Inheritance
(ii) Write the names of all the members, which are directly
accessible by the member function Give() of class Middle.
(iii) Write the names of all the members, which are directly
accessible by the member function Out() of class Top.
(iv) Write the names of all the members, which are directly
accessible by the object T of class Top declared in the main()
function.
OR
91 7 P.T.O.
(d) Consider the following class HeadQuarter 4
class HeadQuarter
{
int Code;
char Des[20];
protected :
char Address[40];
public:
void Get(){cin>>Code;gets(Des);gets(Address);}
void Put(){cout<<Code<<Des<<Address<<endl;}
};
Write a code in C++ to protectedly derive another class FrontOffice
from the base class HeadQuarter with following members.
Data Members
Location of type character of size 10
Budget of type double
Member Functions
A constructor function to assign Budget as 100000
Assign() to allow user to enter Location and Budget
Display() to display Location and Budget

3. (a) Write a user-defined function NoTwoThree(int Arr[], int N) in


C++, which should display the value of all such elements and their
corresponding locations in the array Arr (i.e. the array index), which
are not multiples of 2 or 3. N represents the total number of
elements in the array Arr, to be checked. 3
Example : If the array Arr contains

0 1 2 3 4
25 8 12 49 9

Then the function should display the output as :


25 at location 0
49 at location 3

OR

91 8
(a) Write a user-defined function ReArrange(int Arr[], int N) in C++,
which should swap the contents of the first half locations of the
array Arr with the contents of the second half locations. N (which is
an even integer) represents the total number of elements in the
array Arr. 3
Example :
If the array Arr contains the following elements (for N = 6)

0 1 2 3 4 5
12 5 7 23 8 10

Then the function should rearrange the array to become

0 1 2 3 4 5
23 8 10 12 5 7
NOTE :
 DO NOT DISPLAY the Changed Array contents.
 Do not use any other array to transfer the contents of array Arr.

(b) Write definition for a function XOXO(char M[4][4]) in C++, which


replaces every occurrence of an X with an O in the array, and vice
versa. 2
For example :

ORIGINAL ARRAY M CHANGED ARRAY M

X X O X O O X O

O X O O X O X X

O O X X X X O O

X X O O O O X X

NOTE :
 DO NOT DISPLAY the Changed Array contents.
 Do not use any other array to transfer the contents of array M.

OR
91 9 P.T.O.
(b) Write definition for a function ColSwap(int A[4][4]) in C++, which
swaps the contents of the first column with the contents of the third
column. 2
For example :

ORIGINAL ARRAY A CHANGED ARRAY A

10 15 20 25 20 15 10 25

30 35 40 45 40 35 30 45

50 55 60 65 60 55 50 65

70 75 80 85 80 75 70 85

NOTE :
 DO NOT DISPLAY the Changed Array contents.

 Do not use any other array to transfer the contents of array A.

(c) Let us assume P[20][10] is a two-dimensional array, which is stored


in the memory along the row with each of its elements occupying
2 bytes, find the address of the element P[10][5], if the address of the
element P[5][2] is 25000. 3

OR

(c) Let us assume P[20][30] is a two-dimensional array, which is stored


in the memory along the column with each of its elements occupying
2 bytes. Find the address of the element P[5][6], if the base address
of the array is 25000. 3

91 10
(d) Write a user-defined function Pop(Book B[], int &T), which pops
the details of a Book, from the static stack of Book B, at the location
T (representing the Top end of the stack), where every Book of the
stack is represented by the following structure : 4
struct Book
{
int Bno;
char Bname[20];
};
OR
(d) For the following structure of Books in C++
struct Book
{
int Bno;
char Bname[20];
Book *Link;
};
Given that the following declaration of class BookStack in C++
represents a dynamic stack of Books :
class BookStack
{
Book *Top; //Pointer with address of Topmost Book
of Stack
public:
BookStack()
{
Top = NULL;
}
void Push(); //Function to push a Book into the
dynamic stack
void Pop(); //Function to pop a Book from the
dynamic stack
~BookStack();
};
Write the definition for the member function void
BookStack::Push(), that pushes the details of a Book into the
dynamic stack of BookStack. 4
91 11 P.T.O.
(e) Evaluate the following Postfix expression, showing the stack contents : 2
250,45,9,/,5,+,20,*,-
OR
(e) Convert the following Infix expression to its equivalent Postfix
expression, showing the stack contents for each step of conversion : 2
A + B * C ^ D - E
4. (a) A text file named MESSAGE.TXT contains some text. Another text
file named SMS.TXT needs to be created such that it would store
only the first 150 characters from the file MESSAGE.TXT.
Write a user-defined function LongToShort() in C++ that would
perform the above task of creating SMS.TXT from the already
existing file MESSAGE.TXT. 3
OR
(a) A text file named CONTENTS.TXT contains some text. Write a
user-defined function LongWords() in C++ which displays all
such words of the file whose length is more than 9 alphabets. For
example : if the file CONTENTS.TXT contains :
"Conditional statements of C++ programming language
are if and switch" 3
Then the function LongWords() should display the output as :
Conditional
statements
programming
(b) Write a user-defined function TotalPrice() in C++ to read each object
of a binary file STOCK.DAT, and display the Name from all such
records whose Price is above 150. Assume that the file STOCK.DAT
is created with the help of objects of class Stock, which is defined
below : 2
class Stock
{
char Name[20]; float Price;

public:
char* RName() { return Name; }
float RPrice() { return Price; }
};
OR

91 12
(b) A binary file DOCTORS.DAT contains records stored as objects of
the following class :
class Doctor
{
int DNo; char Name[20]; float Fees;
public:
int *GetNo() { return DNo; }
void Show()
{ cout<<Dno<<" * " <<Name<< " * " <<Fees<<endl;}
};
Write definition for function Details(int N) in C++, which displays
the details of the Doctor from the file DOCTORS.DAT, whose DNo
matches with the parameter N passed to the function. 2
(c) Find the output of the following C++ code considering that the
binary file STOCK.DAT exists on the hard disk with the following
5 records for the class STOCK containing Name and Price. 1
Name Price
Rice 110
Wheat 60
Cheese 200
Pulses 170
Sauce 150
void main()
{ fstream File
File.open("STOCK.DAT",ios::binary|ios::in);
Stock S;
for (int I=1; I<=2; I++)
{
File.seekg((2*I-1)*sizeof(S));
File.read((char*)&S, sizeof(S));
cout << "Read : " << File.tellg()/sizeof(S)<< endl;
}
File.close();
}
OR

(c) Differentiate between seekg() and tellg(). 1

91 13 P.T.O.
SECTION B
[Only for candidates, who opted for Python]

1. (a) Write the names of any four data types available in Python. 2

(b) Name the Python Library modules which need to be imported to


invoke the following functions : 1
(i) sqrt()
(ii) start()

(c) Rewrite the following code in python after removing all syntax
error(s). Underline each correction done in the code. 2
250 = Number
WHILE Number<=1000:
if Number=>750:
print Number
Number=Number+100
else
print Number*2
Number=Number+50

(d) Find and write the output of the following python code : 2
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print Msg3
91 14
(e) Find and write the output of the following python code : 3

def Changer(P,Q=10):
P=P/Q
Q=P%Q
print P,"#",Q
return P
A=200
B=20
A=Changer(A,B)
print A,"$",B
B=Changer(B)
print A,"$",B
A=Changer(A)
print A,"$",B

(f) What possible output(s) are expected to be displayed on screen at


the time of execution of the program from the following code ? Also
specify the minimum values that can be assigned to each of the
variables BEGIN and LAST. 2

import random

VALUES=[10,20,30,40,50,60,70,80]
BEGIN=random.randint(1,3)
LAST=random.randint(BEGIN,4)

for I in range(BEGIN,LAST+1):
print VALUES[I],"-",

(i) 30 - 40 - 50 - (ii) 10 - 20 - 30 - 40 -

(iii) 30 - 40 - 50 - 60 - (iv) 30 - 40 - 50 - 60 - 70 -

91 15 P.T.O.
2. (a) Write four features of object oriented programming. 2

(b) class Box: #Line 1


L = 10 #Line 2
Type="HARD" #Line 3
def __init__(self,T,TL=30): #Line 4
self.Type = T #Line 5
self.L = TL #Line 6
def Disp(self): #Line 7
print self.Type,Box.Type #Line 8
print self.L,Box.L #Line 9
B1=Box("SOFT",20) #Line 10
B1.Disp() #Line 11
Box.Type="FLEXI" #Line 12
B2=Box("HARD") #Line 13
B2.Disp() #Line 14

Write the output of the above Python code. 2

OR

(b) class Target: #Line 1


def __init__(self): #Line 2
self.X = 20 #Line 3
self.Y = 24 #Line 4
def Disp(self): #Line 5
print self.X,self.Y #Line 6
def __del__(self): #Line 7
print "Target Moved" #Line 8
def One(): #Line 9
T=Target() #Line 10
T.Disp() #Line 11
One() #Line 12

91 16
(i) What are the methods/functions mentioned in Line 2 and
Line 7 specifically known as ?

(ii) Mention the line number of the statement, which will call
and execute the method/function shown in Line 2. 2

(c) Define a class HOUSE in Python with the following specifications : 4

Instance Attributes
- Hno # House Number
- Nor # Number of Rooms
- Type # Type of the House

Methods/function
- AssignType() # To assign Type of House
# based on Number of Rooms as follows :

Nor Type

<=2 LIG

==3 MIG

>3 HIG

- Enter() # To allow user to enter value of


# Hno and Nor. Also, this method should

# call AssignType() to assign Type

- Display() # To display Hno, Nor and Type

91 17 P.T.O.
(d) Answer the questions (i) to (iii) based on the following :
class Furniture(object): #Line 1
def __init__(self,Q): #Line 2
self.Qty = Q
def GetMore(self,TQ): #Line 3
self.Qty =self.Qty+TQ
def FRDisp(self): #Line 4
print self.Qty

class Fixture(object): #Line 5


def __init__(self,TQ): #Line 6
self.Qty=TQ
def GetMore(self,TQ): #Line 7
self.Qty =self.Qty+TQ
def FXDisp(self): #Line 8
print self.Qty

class Flat(Furniture,Fixture): #Line 9


def __init__(self,fno): #Line 10
self.Fno=fno
Q=0
if self.Fno<100:
Q=10
else:
Q=20
Furniture.__init__(self,Q): #Line 11
Fixture.__init__(self,Q): #Line 12
def More(self,Q): #Line 13
Furniture.GetMore(self,Q)
Fixture.GetMore(self,Q)
def FLDisp(self): #Line 14
print self.Fno,
Furniture.FRDisp(self)
Fixture.FXDisp(self)
FL=Flat(101) #Line 15
FL.More(2)
FL.FLDisp()

91 18
(i) Write the type of the inheritance illustrated in the above. 1
(ii) Find and write the output of the above code. 2
(iii) What is the difference between the statements shown in
Line 11 and Line 12 ? 1

OR

(d) Define inheritance. Show brief python example of Single Level,


Multiple and Multilevel Inheritance. 4

3. (a) Consider the following randomly ordered numbers stored in a list :


106, 104, 106, 102, 105, 10
Show the content of list after the First, Second and Third pass of
the selection sort method used for arranging in ascending
order. 3
Note : Show the status of all the elements after each pass very
clearly encircling the changes.

OR

(a) Consider the following randomly ordered numbers stored in a list :


106, 104, 106, 102, 105, 107
Show the content of list after the First, Second and Third pass
of the bubble sort method used for arranging in descending
order. 3
Note : Show the status of all the elements after each pass very
clearly encircling the changes.

(b) Write definition of a method/function AddOddEven(VALUES) to


display sum of odd and even values separately from the list of
VALUES. 3
For example :
If the VALUES contain [15, 26, 37, 10, 22, 13]
The function should display
Even Sum: 58
Odd Sum: 65
OR
91 19 P.T.O.
(b) Write definition of a method/function HowMany(ID,Val) to count
and display number of times the value of Val is present in the list ID. 3
For example :
If the ID contains [115,122,137,110,122,113] and Val contains
122
The function should display
122 found 2 Times

(c) Write QueueUp(Client) and QueueDel(Client) methods/functions


in Python to add a new Client and delete a Client from a List of
Clients names, considering them to act as insert and delete
operations of the Queue data structure. 4
OR
(c) Write PushOn(Book) and Pop(Book) methods/functions in Python
to add a new Book and delete a Book from a List of Book titles,
considering them to act as push and pop operations of the Stack data
structure. 4

(d) Write a python method/function Swapper(Numbers) to swap the


first half of the content of a list Numbers with second half of the
content of list Numbers and display the swapped values. 2
Note : Assuming that the list has even number of values in it.
For example :
If the list Numbers contains
[35,67,89,23,12,45]
After swapping the list content should be displayed as
[23,12,45,35,67,89]
OR
(d) Write a python method/function Count3and7(N) to find and
display the count of all those numbers which are between 1 and N,
which are either divisible by 3 or by 7. 2
For example :
If the value of N is 15
The sum should be displayed as
7
(as 3,6,7,9,12,14,15 in between 1 to 15 are either divisible by 3 or 7)
91 20
(e) Evaluate the following Postfix expression, showing the stack
contents : 2
250,45,9,/,5,+,20,*,-

OR

(e) Convert the following Infix expression to its equivalent Postfix


expression, showing the stack contents for each step of
conversion : 2
A + B * C ^ D - E

4. (a) Write a statement in Python to open a text file WRITEUP.TXT so


that new content can be written in it. 1

OR

(a) Write a statement in Python to open a text file README.TXT so


that existing content can be read from it. 1

(b) Write a method/function ISTOUPCOUNT() in python to read


contents from a text file WRITER.TXT, to count and display the
occurrence of the word ‘‘IS’’ or ‘‘TO’’ or ‘‘UP’’. 2

For example :
If the content of the file is

IT IS UP TO US TO TAKE CARE OF OUR SURROUNDING. IT


IS NOT POSSIBLE ONLY FOR THE GOVERNMENT TO TAKE
RESPONSIBILITY

The method/function should display


Count of IS TO and UP is 6

OR

(b) Write a method/function AEDISP() in python to read lines from a


text file WRITER.TXT, and display those lines, which are starting
either with A or starting with E. 2

91 21 P.T.O.
For example :
If the content of the file is

A CLEAN ENVIRONMENT IS NECESSARY FOR OUR GOOD HEALTH.


WE SHOULD TAKE CARE OF OUR ENVIRONMENT.
EDUCATIONAL INSTITUTIONS SHOULD TAKE THE LEAD.

The method should display


A CLEAN ENVIRONMENT IS NECESSARY FOR OUR GOOD HEALTH.
EDUCATIONAL INSTITUTIONS SHOULD TAKE THE LEAD.

(c) Considering the following definition of class STOCK, write a


method/function COSTLY() in python to search and display Name
and Price from a pickled file STOCK.DAT, where Price of the items
are more than 1000. 3
class Stock :
def __init__(self,N,P):
self.Name=N
self.Price=P
def Show(self):
print self.Name,"@",self.Price
OR
(c) Considering the following definition of class DOCTORS, write a
method/function SPLDOCS() in python to search and display all
the content from a pickled file DOCS.DAT, where Specialisation of
DOCTORS is ‘‘CARDIOLOGY’’. 3
class DOCTORS :
def __init__(self,N,S):
self.Name=N
self.Specialisation=S
def Disp(self):
print self.Name,"#",self.Specialisation

91 22
SECTION C
[For all candidates]

5. Write SQL queries for (i) to (iv) and write outputs for SQL queries (v) to
(viii), which are based on the table given below : 8

Table : TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi
14673 Shaheed Express Jaynagar Amritsar Junction
12314 Sealdah Rajdhani New Delhi Sealdah
12498 Shane Punjab Amritsar Junction New Delhi
12451 Shram Shakti Express Kanpur Central New Delhi
12030 Swarna Shatabdi Amritsar Junction New Delhi

Table : PASSENGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12
P007 13005 N S SINGH MALE 52 2018-05-09
P008 12030 J K SHARMA MALE 65 2018-05-09
P009 12030 R SHARMA FEMALE 58 2018-05-09

NOTE : All Dates are given in ‘YYY-MM-DD’ format.


91 23 P.T.O.
(i) To display details of all Trains which Start from New Delhi.
(ii) To display the PNR, PNAME, GENDER and AGE of all
Passengers whose AGE is below 50.
(iii) To display total number of MALE and FEMALE Passengers.
(iv) To display details of all Passengers travelling in Trains
whose TNO is 12015.
(v) SELECT MAX (TRAVELDATE), MIN(TRAVELDATE) FROM
PASSENGERS WHERE GENDER = 'FEMALE';
(vi) SELECT END, COUNT(*) FROM TRAINS
GROUP BY END HAVING COUNT(*)>1;
(vii) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(viii) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P
WHERE T.TNO = P.TNO AND AGE BETWEEN 50 AND 60;

6. (a) State any one Distributive Law of Boolean Algebra and verify it
using truth table. 2

(b) Draw the Logic Circuit of the following Boolean Expression : 2


A.B + A.C

(c) Derive a Canonical POS expression for a Boolean function F,


represented by the following truth table : 1
X Y Z F(X,Y,Z)
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0

(d) Reduce the following Boolean Expression to its simplest form using
K-Map : 3
F(P,Q,R,S) = (0,1,2,3,5,6,7,10,14,15)
91 24
7. (a) Damodar Mohan has been informed that there had been a backdoor
entry to his computer, which has provided access to his system
through a malicious user/programs, allowing confidential and
personal information to be subjected to theft. It happened because
he clicked a link provided in one of the pop-ups from a website
announcing him to be winner of prizes worth 1 Million Dollars.
Which of the following has caused this out of the following ?
(i) Virus
(ii) Worm
(iii) Trojan Horse
Also, mention, what he should do to prevent this infection. 2

(b) Tarini Wadhawa is in India and she is interested in communicating


with her uncle in Australia. She wants to show one of her own
designed gadgets to him and also wants to demonstrate its working
without physically going to Australia. Which protocol out of the
following will be ideal for the same ? 1
(i) POP3
(ii) SMTP
(iii) VoIP
(iv) HTTP

(c) Give two differences between 3G and 4G telecommunication


technologies. 1

(d) Write the expanded names for the following abbreviated terms used
in Networking and Communications : 2
(i) MBPS
(ii) WAN
(iii) CDMA
(iv) WLL
91 25 P.T.O.
(e) Jonathan and Jonathan Training Institute is planning to set up its
centre in Amritsar with four specialised blocks for Medicine,
Management, Law courses alongwith an Admission block in
separate buildings. The physical distances between these blocks and
the number of computers to be installed in these blocks are given
below. You as a network expert have to answer the queries as raised
by their board of directors as given in (i) to (iv).

Shortest distances between various locations in metres :

Admin Block to Management Block 60


Admin Block to Medicine Block 40
Admin Block to Law Block 60
Management Block to Medicine Block 50
Management Block to Law Block 110
Law Block to Medicine Block 40

Number of Computers installed at various locations are as follows :

Admin Block 150


Management Block 70
Medicine Block 20
Law Block 50

91 26
(i) Suggest the most suitable location to install the main server
of this institution to get efficient connectivity. 1

(ii) Suggest the devices to be installed in each of these buildings


for connecting computers installed within the building out of
the following : 1
 Modem
 Switch
 Gateway
 Router

(iii) Suggest by drawing the best cable layout for effective


network connectivity of the blocks having server with all the
other blocks. 1

(iv) Suggest the most suitable wired medium for efficiently


connecting each computer installed in every building out of
the following network cables : 1
 Co-axial Cable
 Ethernet Cable
 Single Pair Telephone Cable

91 27 P.T.O.
SET-4
Series BVM/C Code No. 91
Candidates must write the Code on the
Roll No.
title page of the answer-book.

 Please check that this question paper contains 28 printed pages.


 Code number given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.
 Please check that this question paper contains 7 questions.
 Please write down the Serial Number of the question before
attempting it.
 15 minute time has been allotted to read this question paper. The question
paper will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the
students will read the question paper only and will not write any answer on the
answer-book during this period.

COMPUTER SCIENCE

Time allowed : 3 hours Maximum Marks : 70

General Instructions :
(i) SECTION A refers to programming language C++.
(ii) SECTION B refers to programming language Python.
(iii) SECTION C is compulsory for all.
(iv) Answer either SECTION A or SECTION B.
(v) It is compulsory to mention on the page 1 in the answer-book whether you
are attempting SECTION A or SECTION B.
(vi) All questions are compulsory within each section.
(vii) Questions 2(b), 2(d), 3 and 4 have internal choices.

91 1 P.T.O.
SECTION A
[Only for candidates, who opted for C++]
1. (a) Which of the following are valid operators in C++ :
(i) +=
(ii) not
(iii) = /
(iv) &&
(v) 
(vi) = =
(vii) ++
(viii) and 2
(b) Write the names of the correct header files, which must be included
to compile the code successfully : 1
void main()
{
char S1[20]="CS", S2[20]="2018";
strcat(S1,S2);
cout<< S1;
}
(c) Rewrite the following C++ program after removing any/all
syntactical error(s). Underline each correction done in the code : 2
Note : Assume all required header files are already included in the
program.
#define Volume(L,B,H) = L*B*H
structure Cube
{
int Length,Breadth,Height;
};
void main()
{
Cube C = [10,15,20];
cout<<Volume(Length,Breadth,Height);
}
(d) Find and write the output of the following C++ program code : 2
Note : Assume all required header files are already included in the
program.
void Convert(char *P1, char *P2)
{
char *Q;
Q=P2;
P2=P1;
P1=Q;
cout<<P1<<"*"<<P2<<endl;
}
void main()
{
char S1[]="One", S2[]="Two";
Convert(S1,S2);
cout<<S1<<"&"<<S2<<endl;
}
91 2
(e) Find and write the output of the following C++ program code : 3
Note : Assume all required header files are already included in the
program.
void Alter(float &I, int J=2)
{
I=I+J;
J=I/J;
cout<<I<<"#"<<J<<endl;
}
void main()
{
float P=25, Q=15;
Alter(P,Q);
Alter(P);
Alter(Q);
}

(f) Observe the following C++ code and find the possible output(s) from
the options (i) to (iv) following it. Also, write the minimum and
maximum values that can possibly be assigned to the variable End. 2
Note :
 Assume all the required header files are already being included in
the code.
 The function random(N) generates any possible integer between
0 and N-1 (both values included).

void main()
{
randomize();
int A[]={5,10,15,20,25,30,35,40};
int Start = random(2) + 1;
int End = Start + random(4);
for(int I=Start; I<=End, I++)
cout<<A[I]<<"*";
}

(i) 20*25*30*35* (ii) 15*20*25*30*


(iii) 5*15*20 (iv) 10*15*20*25*30*

91 3 P.T.O.
2. (a) Given the following class Exam and assuming all necessary header
file(s) included, answer the questions that follow the code :
class Exam
{
int Marks; char EName[20];
public:
Exam (int M) //Function 1
{
Marks = M;
}
Exam (char S[]) //Function 2
{
strcpy(EName,S);
}
Exam (char S[], int M) //Function 3
{
Marks = M;
strcpy(EName,S);
}
Exam (Exam &E) //Function 4
{
Marks = E.Marks + 10;
strcpy(EName,E.EName);
}
};

void main()
{
Exam E1(10); //Statement I
Exam E2(70); //Statement II
Exam E4("THEORY",70); //Statement III
_______________; //Statement IV
}

(i) Which of the statement(s) out of (I), (II), (III), (IV) is/are
incorrect for object(s) of the class Exam ? 1

(ii) What is Function 4 known as ? Write the Statement IV,


that would execute Function 4. 1

91 4
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.

class Coordinate
{
int X,Y;
public:
Coordinate(int I=20, int J=10) //Function 1
{
X = J; Y = I;
}
void Show() //Function 2
{
cout<< " Coordinates are " << X << " & " << Y <<endl;
}
~Coordinate() //Function 3
{
cout<<"Erased "<<endl;
}
};

void main()
{
Coordinate C(15);
C.Show();
}

(i) For the class Coordinate, what is Function 3 known as ?


When is it executed ? 1

(ii) What is the output of the above code, on execution ? 1

OR

(b) Explain Constructor Overloading in context of Object Oriented


Programming. Also give a supporting example in C++. 2

91 5 P.T.O.
(c) Write the definition of a class STATS in C++ with following
description : 4

Private Members

 Code // integer

 Tests // an array of integer with 3 elements

 Avg // integer

 CalAvg() /* Member function to calculate Avg

as Average of values given in

array Tests */

Public Members

 In() /* Function to allow user to enter values

of Code and Tests and then invoke

CalAvg() to calculate average */

 Out() // Function to display all data members

91 6
(d) Answer the questions (i) to (iv) based on the following : 4
class GFloor
{
int GRooms;
protected:
void Give();
public:
void Take();
};

class FFloor : private GFloor


{
int FRooms;
public:
void Get(); void Put();
};

class SFloor : public FFloor


{
int SRooms;
public:
void Input(); void Output();
};

void main()
{
SFloor S;
}
(i) Which type of Inheritance out of the following is illustrated
in the above example ?
 Single Level Inheritance, Multilevel Inheritance,
Multiple Inheritance
(ii) Write the names of all the members, which are directly
accessible by the member function Get() of class FFloor.
(iii) Write the names of all the members, which are directly
accessible by the member function Input() of class SFloor.
(iv) Write the names of all the members, which are directly
accessible by the object S of class SFloor declared in the
main() function.
OR

91 7 P.T.O.
(d) Consider the following class Institution 4
class Institution
{
int Code;
char Course[20];
protected :
float Fee;

public:
void Reg(){cin>>Code;gets(Course);cin>>Fee;}
void Show(){cout<<Code<<Course<<Fee<<endl;}
};
Write a code in C++ to publicly derive another class Student from
the base class Institution with following members.

Data Members
Rno of type long
Name of type character of size 10
Member Functions
A constructor function to assign Rno as 100
Admit() to allow user to enter Rno and Name
Display() to display Rno and Name

3. (a) Write a user-defined function NoThreeFive(int Arr[], int N) in


C++, which should display the value of all such elements and their
corresponding locations in the array Arr (i.e. the array index), which
are not multiples of 3 or 5. N represents the total number of
elements in the array Arr, to be checked. 3
Example : If the array Arr contains

0 1 2 3 4
25 8 15 49 9

Then the function should display the output as


8 at location 1
49 at location 3
OR
91 8
(a) Write a user-defined function HalfReverse(int Arr[], int N) in
C++, which should first reverse the contents of the first half of the
array Arr and then reverse the contents of the second half of the
array Arr. The total number of elements in the array Arr is
represented by N (which is an even integer). 3
Example : If the array Arr contains the following elements (for N = 6)
0 1 2 3 4 5
12 5 7 23 8 10

Then the function should rearrange the array to become

0 1 2 3 4 5
7 5 12 10 8 23
NOTE :
 DO NOT DISPLAY the Changed Array contents.
 Do not use any other array to transfer the contents of array Arr.

(b) Write a user-defined function OneZero(int M[4] [4]) in C++, which


replaces every occurrence of a 1 with a 0 in the array, and vice versa. 2
For example :

ORIGINAL ARRAY M CHANGED ARRAY M

1 1 0 1 0 0 1 0

0 1 0 0 1 0 1 1

0 0 1 1 1 1 0 0

1 1 0 0 0 0 1 1

NOTE :
 DO NOT DISPLAY the Changed Array contents.
 Do not use any other array to transfer the contents of array M.

OR

91 9 P.T.O.
(b) Write a user-defined function RowSwap(int A [4] [4]) in C++,
which swaps the contents of the first row with the contents of the
third row. 2

For example :

ORIGINAL ARRAY A CHANGED ARRAY A

10 15 20 25 50 55 60 65

30 35 40 45 30 35 40 45

50 55 60 65 10 15 20 25

70 75 80 85 70 75 80 85

NOTE :

 DO NOT DISPLAY the Changed Array contents.

 Do not use any other array to transfer the contents of array A.

(c) Let us assume P[20][30] is a two-dimensional array, which is stored


in the memory along the column with each of its elements occupying
2 bytes, find the address of the element P[3][5], if the address of the
array is 45000. 3

OR

(c) Let us assume P[10][20] is a two-dimensional array, which is stored


in the memory along the row with each of its elements occupying
2 bytes, find the address of the element P[5][10], if the address of the
element P[2][15] is 25000. 3

91 10
(d) For the following structure of Items in C++
struct Item
{
char Name[20];
float Price;
Item *Link;
};
Given that the following declaration of class ItemStack in C++
represents a dynamic stack of Items :
class ItemStack
{
Item *Top; //Pointer with address of Topmost Item
of Stack
public:
ItemStack()
{
Top = NULL;
}
void Push(); //Function to push an Item into the
dynamic stack
void Pop(); //Function to pop an Item from the
dynamic stack
~ItemStack();
};
Write the definition for the member function void ItemStack::Pop(),
that pops the details of an Item from the dynamic stack of
ItemStack. 4
OR
(d) Write a user-defined function Push(Item S[], int &T), which
pushes the details of an Item, into the static stack of Items S, at the
location T (representing the Top end of the stack), where every Item
to be pushed into the stack is represented by the following structure : 4
struct Item
{
char Name[20];
float Price;
};
91 11 P.T.O.
(e) Convert the following Infix expression to its equivalent Postfix
expression, showing the stack contents for each step of conversion : 2
P – Q / R ^ S + T
OR
(e) Evaluate the following Postfix expression, showing the stack
contents : 2
150,25,5,/,45,+,2,*,-
4. (a) A text file named IONS.TXT contains some text. Write a
user-defined function ShowP() in C++ which displays all
such words of the file which start with alphabet 'P'. 3
For example : If the file IONS.TXT contains :
"Whether an atom will form a cation or an anion is
based on its position in the periodic table"
Then the function ShowP() should display the output as
position, periodic
OR
(a) A text file named BIG.TXT contains some text. Another text file
named SMALL.TXT needs to be created such that it would store
only the first 50 characters from the file BIG.TXT.
Write a user-defined function BigToSmall() in C++ that would
perform the above task of creating SMALL.TXT from the already
existing file BIG.TXT. 3

(b) A binary file CUSTOMER.DAT contains records stored as objects of


the following class :
class Customer
{
int CNo; char Name[20]; char Address[30];
public:
int *GetNo() { return CNo; }
void Show()
{ cout<<CNo<<" * " <<Name<< " * " <<Address<<endl;
};
Write a user-defined function Search(int N) in C++, which displays
the details of the Customer from the file CUSTOMER.DAT, whose
CNo matches with the parameter N passed to the function. 2
OR

91 12
(b) Write a user-defined function TotalCost() in C++ to read each object
of a binary file ITEMS.DAT, and display the Name from all such
records, whose Cost is above 150. Assume that the file ITEMS.DAT is
created with the help of objects of class Item, which is defined
below : 2
class Item
{
char Name[20]; float Cost;
public:
char* RName() { return Name; }
float RCost() { return Cost; }
};

(c) Find the output of the following C++ code considering that the
binary file ITEMS.DAT exists on the hard disk with the following
5 records for the class Item containing Name and Cost. 1
Name Cost
Rice 110
Wheat 60
Cheese 200
Pulses 170
Sauce 150
void main()
{
fstream File;
File.open("ITEMS.DAT",ios::binary|ios::in);
Item T;
for (int I=1; I<=2; I++)
{
File.seekg((2*I-1)*sizeof(T));
File.read((char*)&T, sizeof(T));
cout<<"Read :"<<File.tellg()/sizeof(T)<<endl;
}
File.close();
}
OR

(c) Differentiate between ios::out and ios::app file modes. 1

91 13 P.T.O.
SECTION B
[Only for candidates, who opted for Python]
1. (a) Which of the following are valid operators in Python ? 2
(i) +=
(ii) ^
(iii) in
(iv) &&
(v) between
(vi) */
(vii) is
(viii) like

(b) Name the Python Library modules which need to be imported to


invoke the following functions : 1
(i) open()
(ii) factorial()
(c) Rewrite the following code in Python after removing all syntax
error(s). Underline each correction done in the code. 2
"HELLO"=String
for I in range(0,len(String)–1)
if String[I]=>"M":
print String[I],"*"
Else:
print String[I-1]

(d) Find and write the output of the following Python code : 2
Str1="EXAM2018"
Str2=""
I=0
while I<len(Str1):
if Str1[I]>="A" and Str1[I]<="M":
Str2=Str2+Str1[I+1]
elif Str1[I]>="0" and Str1[I]<="9":
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+"*"
I=I+1
print Str2
91 14
(e) Find and write the output of the following Python code : 3

def Alter(P=15,Q=10):
P=P*Q
Q=P/Q
print P,"#",Q
return Q
A=100
B=200
A=Alter(A,B)
print A,"$",B
B=Alter(B)
print A,"$",B
A=Alter(A)
print A,"$",B

(f) What possible output(s) are expected to be displayed on screen at


the time of execution of the program from the following Python
code ? Also specify the minimum values that can be assigned to each
of the variables BEGIN and LAST. 2

import random

VAL=[80,70,60,50,40,30,20,10]
Start=random.randint(1,3)
End=random.randint(Start,4)

for I in range(Start,End+1):
print VAL[I],"*",

(i) 40 * 30 * 20 * 10 * (ii) 70 * 60 * 50 * 40 * 30 *

(iii) 50 * 40 * 30 * (iv) 60 * 50 * 40 * 30 *

91 15 P.T.O.
2. (a) What is an Abstract Method in a class of Python ? Write a code in
Python to illustrate use of an Abstract Method in Python. 2
(b) class Matter:
Vol = 10
Type="SOLID"
def __init__(self,T,V=30):
self.Type = T
self.Vol = V
def Disp(self):
print self.Type,Matter.Type
print self.Vol,Matter.Vol
M1=Matter("GAS",20)
M1.Disp()
Matter.Type="LIQUID"
M2=Matter("SOLID")
M2.Disp()

(b) Write the output of the above Python code. 2

OR

class Point: #Line 1


def __init__(self): #Line 2
self.X = 20 #Line 3
self.Y = 24 #Line 4
def Show(self): #Line 5
print self.X,self.Y #Line 6
def __del__(self): #Line 7
print "Point Moved" #Line 8
def Fun(): #Line 9
P=Point() #Line 10
P.Show() #Line 11
Fun() #Line 12
91 16
(i) What are the methods/functions mentioned in Line 2 and
Line 7 specifically known as ?

(ii) Mention the line number of the statement, which will call
and execute the method/function shown in Line 2. 2

(c) Define a class TRANSPORT in Python with the following


specifications : 4

Instance Attributes
- Vno # Vehicle Number
- Vehicle # Vehicle Name
- Type # Type of the Vehicle

Methods/Functions
- FindType() # To assign Type of Vehicle
# based on Name of the Vehicle as shown
# below :

Vehicle Type

MotorCycle MCYCL

Car MTV

Truck HTV

Bus HTV

- Enter() # To allow user to enter value of


# Vno and Vehicle. Also, this method should

# call FindType() to assign Type

- Display() # To display Vno, Vehicle and Type

91 17 P.T.O.
(d) Answer the questions (i) to (iii) based on the following :
class Super(object): #Line 1
def __init__(self,n): #Line 2
self.N = n
def Set(self,n): #Line 3
self.n =self.N+n
def SPShow(self): #Line 4
print self.N

class Top(object): #Line 5


def __init__(self,n): #Line 6
self.N=n
def Set(self,n): #Line 7
self.N =self.N+n
def TPShow(self): #Line 8
print self.N

class Bottom(Super,Top): #Line 9


def __init__(self,d): #Line 10
self.D=d
n=0
if self.D<10:
n=5
else:
n=10
Super.__init__(self,n) #Line 11
Top.__init__(self,n) #Line 12
def SetAll(self,n): #Line 13
Super.Set(self,n)
Top.Set(self,n)
def BTShow(self): #Line 14
print self.D,
Super.SPShow(self)
Top.TPShow(self)
B=Bottom(101) #Line 15
B.SetA11(7)
B.BTShow()
91 18
(i) Write the type of the inheritance illustrated in the above. 1
(ii) Find and write the output of the above code. 2
(iii) What is the difference between the statements shown in
Line 11 and Line 12 ? 1

OR

(d) Define Inheritance. Show brief Python example of Single Level,


Multiple and Multilevel Inheritance. 4

3. (a) Consider the following randomly ordered numbers stored in a list :


601, 430, 160, 120, 215, 127
Show the content of list after the First, Second and Third pass of
the selection sort method used for arranging in ascending
order. 3
Note : Show the status of all the elements after each pass very
clearly encircling the changes.

OR

(a) Consider the following randomly ordered numbers stored in a list :


601, 430, 160, 120, 215, 127
Show the content of list after the First, Second and Third pass
of the bubble sort method used for arranging in descending
order. 3
Note : Show the status of all the elements after each pass very
clearly encircling the changes.

(b) Write definition of a method/function DoubletheOdd(Nums) to add


and display twice of odd values from the list of Nums. 3
For example :
If the Nums contains [25,24,35,20,32,41]
The function should display
Twice of Odd Sum: 202
OR

91 19 P.T.O.
(b) Write definition of a method/function FindOut(Names, HisName)
to search for HisName string from a list Names, and display the
position of its presence. 3
For example :
If the Names contain ["Arun","Raj","Tarun","Kanika"]
and HisName contains "Tarun"

The function should display


Tarun at 2

(c) Write InsQueue(Passenger) and DelQueue(Passenger)


methods/function in Python to add a new Passenger and delete a
Passenger from a list of Passenger names, considering them to act
as insert and delete operations of the Queue data structure. 4

OR

(c) Write DoPush(Customer) and DoPop(Customer)


methods/function in Python to add a new Customer and delete a
Customer from a List of Customer names, considering them to act as
push and pop operations of the Stack data structure. 4

(d) Write a Python method/function SwitchOver(Val) to swap the even


and odd positions of the values in the list Val. 2

Note : Assuming that the list has even number of values in it.
For example :
If the list Numbers contain
[25,17,19,13,12,15]
After swapping the list content should be displayed as
[17,25,13,19,15,12]
OR

91 20
(d) Write a Python method/function Count(Start,End,Step) to display
natural numbers from Start. 2
End in equal intervals of Step
For example :
If the values of Start as 14, End as 35 and Step as 6
The method should be displayed as
14
20
26
32

(e) Evaluate the following Postfix expression, showing the stack


contents : 2
25,5,*,15,3,/,+,10,-

OR

(e) Convert the following Infix expression to its equivalent Postfix


expression, showing the stack contents for each step of
conversion : 2
P * Q + R / S – T

4. (a) Write a statement in Python to open a text file CONTENT.TXT so


that new contents can be written in it. 1

OR

(a) Write a statement in Python to open a text file REMARKS.TXT so


that existing content can be read from it. 1

91 21 P.T.O.
(b) Write a method/function BIGWORDS() in Python to read contents
from a text file CODE.TXT, to count and display the occurrence of
those words, which are having 5 or more alphabets. 2

For example :
If the content of the file is

ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE

The method/function should display


Count of big words is 5

OR

(b) Write a method/function BIGLINES() in Python to read lines from a


text file CONTENT.TXT, and display those lines, which are bigger
than 20 characters. 2

For example :
If the content of the file is

Stay positive and happy


Work hard and dont give up hope
Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people

The method/function should display


Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people

91 22
(c) Considering the following definition of class ITEMS, write a
method/function LowStock() in Python to search and display
Iname and Qty from a pickled file STOCK.DAT, for the items, whose
Qty is less than 10. 3

class ITEMS :

def __init__(self,I,Q):

self.Iname=N

self.Qty=Q

def IDisp(self):

print self.Iname,"@",self.Qty

OR

(c) Considering the following definition of class MEMBERS, write a


method/function MONTHLYMEMBERS() in Python to search and
display all the content from a pickled file MEMBERS.DAT, where
Type of MEMBERS is ‘‘MONTHLY’’. 3
class MEMBERS :

def __init__(self,N,T):
self.Name=N
self.Type=T
def Disp(self):
print self.Name,"$",self.Type

91 23 P.T.O.
SECTION C
[For all candidates]

5. (a) Observe the following table STOCK carefully and answer the
questions that follow : 2
Table : STOCK
SNO NAME PRICE
101 PEN 50
102 PENCIL 5
103 PENCIL 10
104 NOTEBOOK 50
105 ERASER 5

Which attribute out of SNO, NAME and PRICE is the ideal one for
being considered as the Primary Key and why ?

(b) Write SQL queries for (i) to (iv) and write outputs for SQL queries
(v) to (viii), which are based on the tables given below : 6

Table : TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi
14673 Shaheed Express Jaynagar Amritsar Junction
12314 Sealdah Rajdhani New Delhi Sealdah
12498 Shan-e-Punjab Amritsar Junction New Delhi
12451 Shram Shakti Express Kanpur Central New Delhi
12030 Swarna Shatabdi Amritsar Junction New Delhi

91 24
Table : PASSENGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12
P007 13005 N S SINGH MALE 52 2018-05-09
P008 12030 J K SHARMA MALE 65 2018-05-09
P009 12030 R SHARMA FEMALE 58 2018-05-09

NOTE : All Dates are given in ‘YYYY-MM-DD’ format.

(i) To display total number of MALE and FEMALE Passengers


(ii) To display details of all Trains which Start from Pune
Junction
(iii) To display details of all Passengers travelling in Trains
whose TNO is 12030
(iv) To display the PNR, PNAME, GENDER and AGE of all
Passengers whose AGE is above 50.
(v) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(vi) SELECT MIN (TRAVELDATE), MAX (TRAVELDATE) FROM
PASSENGERS WHERE GENDER = 'MALE';
(vii) SELECT START, COUNT(*) FROM TRAINS
GROUP BY START HAVING COUNT (*)>1;
(viii) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P
WHERE T.TNO = P.TNO AND AGE BETWEEN 40 AND 50;

6. (a) State any one Absorption Law of Boolean Algebra and verify it using
truth table. 2

(b) Draw the Logic Circuit of the following Boolean Expression : 2


A.B + A.C
91 25 P.T.O.
(c) Derive a Canonical POS expression for a Boolean function F,
represented by the following truth table : 1
X Y Z F(X,Y,Z)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

(d) Reduce the following Boolean Expression to its simplest form using
K-Map : 3
F(P,Q,R,S) = (2,6,7,8,9,10,11,13,14,15)

7. (a) William Jones has got a file that is replicating itself in order to
spread to other computers using computer network on its own,
relying on security failures on the target computer to access it. It is
consuming a lot of network bandwidth also. Which of the following
type category of infection will it be considered ? Also, mention, what
should he do to prevent this infection ? 2
(i) Virus
(ii) Worm
(iii) Trojan Horse

(b) Dr. Theekkar Singh is a very experienced orthopaedician in the Ilaj


Nagar City. He is planning to connect 5 of his clinics of the city with
a personalised application for his appointment organization without
using mobile/web application. Which out of the following networks
would be suitable ? 1
(i) PAN
(ii) LAN
(iii) MAN
(iv) WAN
91 26
(c) Select two server side scripting languages out of the following ? 1
(i) ASP
(ii) VBScript
(iii) JavaScript
(iv) PHP

(d) Write the expanded names for the following abbreviated terms used
in Networking and Communications : 2
(i) HTML
(ii) PAN
(iii) TCP
(iv) GBPS

(e) CASE STUDY BASED QUESTION

Piccadily Design and Training Institute is setting up its centre in


Jodhpur with four specialised units for Design, Media, HR and
Training in separate buildings. The physical distances between
these units and the number of computers to be installed in these
units are given as follows.

You as a network expert, have to answer the queries as raised by the


administrator as given in (i) to (iv).

Shortest distances between various locations in metres :

Design Unit to Media Unit 60


Design Unit to HR Unit 40
Design Unit to Training Unit 60
Media Unit to Training Unit 100
Media Unit to HR Unit 50
Training Unit to HR Unit 60

91 27 P.T.O.
Number of computers installed at various locations are as follows :

Design Unit 40
Media Unit 50
HR Unit 110
Training Unit 40

(i) Suggest the most suitable location to install the main server
of this institution to get efficient connectivity. 1

(ii) Suggest by drawing the best cable layout for effective


network connectivity of the building having server with all
the other units. 1

(iii) Suggest the devices to be installed in each of these buildings


for connecting computers installed within each of the units
out of the following : 1

Modem, Switch, Gateway, Router

(iv) Suggest an efficient as well as economic wired medium to be


used within each unit for connecting computer systems out of
the following network cable : 1

Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.

91 28
Code No. 91/C
Candidates must write the Code on the
Roll No.
title page of the answer-book.

 Please check that this question paper contains 12 printed pages.


 Code number given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.
 Please check that this question paper contains 5 questions.
 Please write down the Serial Number of the question in the answer-book before
attempting it.
 15 minute time has been allotted to read this question paper. The question
paper will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the
students will read the question paper only and will not write any answer on the
answer-book during this period.

COMPUTER SCIENCE (NEW)


Time allowed : 3 hours Maximum Marks : 70

General Instructions :

(i) All questions are compulsory.

(ii) Question paper is divided into four sections  A, B, C and D.


• Section A : Unit-1 30
• Section B : Unit-2 15
• Section C : Unit-3 15
• Section D : Unit-4 10

.91/D 1 P.T.O.
SECTION A
1. (a) Which of the following is not a valid variable name in Python ?
Justify reason for it not being a valid name. 1
(i) 5Radius
(ii) Radius_
(iii) _Radius
(iv) Radius
(b) Which of the following are keywords in Python ? 1
(i) break
(ii) check
(iii) range
(iv) while
(c) Name the Python Library modules which need to be imported to
invoke the following functions : 1
(i) cos()
(ii) randint()
(d) Rewrite the following code in Python after removing all syntax
error(s). Underline each correction done in the code. 2
input('Enter a word',W)
if W = 'Hello'
print('Ok')
else:
print('Not Ok')
(e) Find and write the output of the following Python code : 2
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i] //= 5
if M[i]%3 == 0:
M[i] //= 3
L=[25,8,75,12]
ChangeVal(L,4)
for i in L :
print(i, end='#')
.91/D 2
(f) Find and write the output of the following Python code : 3
def Call(P=40,Q=20):
P=P+Q
Q=P–Q
print(P,'@',Q)
return P
R=200
S=100
R=Call(R,S)
print (R,'@',S)
S=Call(S)
print(R,'@',S)

(g) What possible output(s) are expected to be displayed on screen at


the time of execution of the program from the following code ? Also
specify the minimum and maximum values that can be assigned to
the variable End. 2
import random

Colours = ["VIOLET","INDIGO","BLUE","GREEN",
"YELLOW","ORANGE","RED"]

End = randrange(2)+3
Begin = randrange(End)+1
for i in range(Begin,End):
print(Colours[i],end="&")
(i) INDIGO&BLUE&GREEN& (ii) VIOLET&INDIGO&BLUE&
(iii) BLUE&GREEN&YELLOW& (iv) GREEN&YELLOW&ORANGE&

2. (a) Write the names of the immutable data objects from the following : 1
(i) List
(ii) Tuple
(iii) String
(iv) Dictionary
.91/D 3 P.T.O.
(b) Write a Python statement to declare a Dictionary named ClassRoll
with Keys as 1, 2, 3 and corresponding values as 'Reena',
'Rakesh', 'Zareen' respectively. 1

(c) Which of the options out of (i) to (iv) is the correct data type for the
variable Vowels as defined in the following Python statement ? 1
Vowels = ('A', 'E', 'I', 'O', 'U')
(i) List
(ii) Dictionary
(iii) Tuple
(iv) Array

(d) Write the output of the following Python code : 1


for i in range(2,7,2):
print(i * '$')

(e) Write the output of the following Python code : 1


def Update(X=10):
X += 15
print('X = ', X)

X=20
Update()
print('X = ', X)
(f) Differentiate between ‘‘w’’ and ‘‘r’’ file modes used in Python.
Illustrate the difference using suitable examples. 2
(g) A pie chart is to be drawn (using pyplot) to represent Pollution Level
of Cities. Write appropriate statements in Python to provide labels
for the pie slices as the names of the Cities and the size of each pie
slice representing the corresponding Pollution of the Cities as per
the following table : 2
Cities Pollution
Mumbai 350
Delhi 475
Chennai 315
Bangalore 390

OR
.91/D 4
Write the output from the given Python code : 2

import matplotlib.pyplot as plt


Months = ['Dec','Jan','Feb','Mar']
Marks = [70, 90, 75, 95]
plt.bar(Months, Attendance)
plt.show()

(h) Write a function Show_words() in Python to read the content of a


text file 'NOTES.TXT' and display the entire content in capital
letters. Example, if the file contains : 2
"This is a test file"
Then the function should display the output as :
THIS IS A TEST FILE

OR

Write a function Show_words() in Python to read the content of a


text file 'NOTES.TXT' and display only such lines of the file which
have exactly 5 words in them. Example, if the file contains : 2
This is a sample file.
The file contains many sentences.
But needs only sentences which have only 5 words.
Then the function should display the output as :
This is a sample file.
The file contains many sentences :

(i) Write a Recursive function in Python RecsumNat(N), to return the


sum of the first N natural numbers. For example, if N is 10 then the
function should return (1 + 2 + 3 + ... + 10 = 55). 3

OR

.91/D 5 P.T.O.
Write a Recursive function in Python Power(X,N), to return the
result of X raised to the power N where X and N are non-negative
integers. For example, if X is 5 and N is 3 then the function should
return the result of (5)3 i.e. 125. 3

(j) Write functions in Python for PushS(List) and for PopS(List) for
performing Push and Pop operations with a stack of List containing
integers. 4

OR

Write functions in Python for InsertQ(Names) and for


RemoveQ(Names) for performing insertion and removal operations
with a queue of List which contains names of students. 4

SECTION B
3. Fill in the blanks from questions 3(a) to 3(d).

(a) Computers connected by a network across different cities is an


example of ___________ . 1

(b) ___________ is a network tool used to test the download and upload
broadband speed. 1

(c) A ____________ is a networking device that connects computers in a


network by using packet switching to receive, and forward data to
the destination. 1

(d) ___________ is a network tool used to determine the path packets


taken from one IP address to another. 1

(e) Write the full form of the following abbreviations : 2

(i) POP

(ii) VoIP

(iii) NFC

(iv) FTP
.91/D 6
(f) Match the ServiceNames listed in the first column of the following
table with their corresponding features listed in the second column
of the table : 2

Technology Feature
 IP based Protocols (LTE)
1G
 True Mobile Broadband
 Improved Data Services with
2G Multimedia
 Mobile Broadband
 Basic Voice Services
3G
 Analog-based Protocol
 Better Voice Services
4G  Basic Data Services
 First Digital Standards (GSM, CDMA)

(g) What is a secure communication ? Differentiate between HTTP and


HTTPS. 3

(h) Helping Hands is an NGO with its head office at Mumbai and
branches located at Delhi, Kolkata and Chennai. Their Head Office
located at Delhi needs a communication network to be established
between the head office and all the branch offices. The NGO has
received a grant from the national government for setting up the
network. The physical distances between the branch offices and the
head office and the number of computers to be installed in each of
these branch offices and the head office are given below. You, as a
network expert, have to suggest the best possible solutions for the
queries as raised by the NGO, as given in (i) to (iv).

.91/D 7 P.T.O.
Distances between various locations in Kilometres :

Mumbai H.O. to Delhi 1420


Mumbai H.O. to Kolkata 1640
Mumbai H.O. to Chennai 2710
Delhi to Kolkata 1430
Delhi to Chennai 1870
Chennai to Kolkata 1750

Number of computers installed at various locations are as follows :

Mumbai H.O. 2500


Delhi branch 1200
Kolkata branch 1300
Chennai branch 1100

(i) Suggest by drawing the best cable layout for effective


network connectivity of all the Branches and the Head Office
for communicating data. 1

(ii) Suggest the most suitable location to install the main server
of this NGO to communicate data with all the offices. 1

.91/D 8
(iii) Write the name of the type of network out of the following,
which will be formed by connecting all the computer systems
across the network : 1
(A) WAN
(B) MAN
(C) LAN
(D) PAN

(iv) Suggest the most suitable medium for connecting the


computers installed across the network out of the following : 1
(A) Optical fibre
(B) Telephone wires
(C) Radio waves
(D) Ethernet cable
SECTION C
4. (a) Which SQL command is used to add a new attribute in a table ? 1

(b) Which SQL aggregate function is used to count all records of a


table ? 1

(c) Which clause is used with a SELECT command in SQL to display


the records in ascending order of an attribute ? 1

(d) Write the full form of the following abbreviations : 1


(i) DDL
(ii) DML

(e) Observe the following tables, EMPLOYEES and DEPARTMENT


carefully and answer the questions that follow : 2
TABLE : EMPLOYEES TABLE : DEPARTMENT
ENO ENAME DOJ DNO DNO DNAME
E1 NUSRAT 2001-11-21 D3 D1 ACCOUNTS
E2 KABIR 2005-10-25 D1 D2 HR
D3 ADMIN

.91/D 9 P.T.O.
(i) What is the Degree of the table EMPLOYEES ? What is the
cardinality of the table DEPARTMENT ?
(ii) What is a Primary Key ? Explain.

OR

Differentiate between Selection and Projection operations in context


of a Relational Database. Also, illustrate the difference with one
supporting example of each. 2

(f) Write whether the following statements are True or False for the
GET and POST methods in Django : 2
(i) POST requests are never cached.
(ii) GET requests do not remain in the browser history.

(g) Write outputs for SQL queries (i) to (iii), which are based on the
following tables, CUSTOMERS and PURCHASES : 3
Table : CUSTOMERS Table : PURCHASES
CNO CNAME CITIES SNO QTY PUR_DATE CNO
C1 SANYAM DELHI S1 15 2018-12-25 C2O
C2 SHRUTI DELHI S2 10 2018-11-10 C1
C3 MEHER MUMBAI S3 12 2018-11-10 C4
C4 SAKSHI CHENNAI S4 7 2019-01-12 C7
C5 RITESH INDORE S5 11 2019-02-12 C2
C6 RAHUL DELHI S6 10 2018-10-12 C6
C7 AMEER CHENNAI S7 5 2019-05-09 C8
C8 MINAKSHI BANGALORE S8 20 2019-05-09 C3
C9 ANSHUL MUMBAI S9 8 2018-05-09 C9
S10 15 2018-11-12 C5
S11 6 2018-08-04 C7

(i) SELECT COUNT(DISTINCT CITIES) FROM CUSTOMERS;

(ii) SELECT MAX(PUR_DATE) FROM PURCHASES;


(iii) SELECT CNAME, QTY, PUR_DATE FROM CUSTOMERS,
PURCHASES WHERE CUSTOMERS.CNO = PURCHASES.CNO
AND QTY IN (10,20);

.91/D 10
(h) Write SQL queries for (i) to (iv), which are based on the tables :
CUSTOMERS and PURCHASES given in the question 4(g) : 4

(i) To display details of all CUSTOMERS whose CITIES are


neither Delhi nor Mumbai.
(ii) To display the CNAME and CITIES of all CUSTOMERS in
ascending order of their CNAME.
(iii) To display the number of CUSTOMERS along with their
respective CITIES in each of the CITIES.
(iv) To display details of all PURCHASES whose Quantity is
more than 15.

SECTION D

5. (a) An organisation purchases new computers every year and dumps


the old ones into the local dumping yard. Write the name of the most
appropriate category of waste that the organisation is creating every
year, out of the following options : 1
(i) Solid Waste
(ii) Commercial Waste
(iii) E-Waste
(iv) Business Waste

(b) Data which has no restriction of usage and is freely available to


everyone under Intellectual Property Rights is categorised as 1
(i) Open Source
(ii) Open Data
(iii) Open Content
(iv) Open Education

(c) What is a Unique Id ? Write the name of the Unique Identification


provided by Government of India for Indian Citizens. 2

.91/D 11 P.T.O.
(d) Consider the following scenario and answer the questions which
follow : 2
‘‘A student is expected to write a research paper on a topic. The
student had a friend who took a similar class five years ago. The
student asks his older friend for a copy of his paper and then
takes the paper and submits the entire paper as his own research
work.’’
(i) Which of the following activities appropriately categorises
the act of the writer ?
(A) Plagiarism
(B) Spamming
(C) Virus
(D) Phishing
(ii) Which kind of offense out of the following is made by the
student ?
(A) Cyber Crime
(B) Civil Crime
(C) Violation of Intellectual Property Rights

(e) What are Digital Rights ? Write examples for two digital rights
applicable to usage of digital technology. 2

(f) Suggest techniques which can be adopted to impart Computer


Education for
(i) Visually impaired students (someone who cannot write).
(ii) Speech impaired students (someone who cannot speak). 2

.91/D 12
Series /C SET~4
Code No. 91
Roll No.
Candidates must write the Code on the
title page of the answer-book.

NOTE :
(i) Please check that this question paper contains 13 printed pages.

(ii) Code number given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.

(iii) Please check that this question paper contains 40 questions.

(iii) Please write down the serial number of the question in the answer-book before
attempting it.

(iv) 15 minute time has been allotted to read this question paper. The question paper
will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the students
will read the question paper only and will not write any answer on the
answer-book during this period.

COMPUTER SCIENCE (NEW)

Time allowed : 3 hours Maximum Marks : 70

91 Page 1 P.T.O.
General Instructions :
(i) This question paper contains two parts Part A and B. Each part is compulsory.
(ii) Both Part A and Part B have choices.
(iii) Part A has two sections :
a. Section I is short answer questions, to be answered in one word or one line.
b. Section II has two case study-based questions. Each case study has
5 case-based subparts. An examinee is to attempt any 4 out of the 5 subparts.
(iv) Part B is Descriptive Paper.
(v) Part B has three sections :
a. Section I is short answer questions of 2 marks each in which two questions have
internal options.
b. Section II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section III is very long answer questions of 5 marks each in which one question has
an internal option.
(vi) All programming questions are to be answered using Python Language only.

PART A
Section I

Select the most appropriate option out of the options given for each question. Attempt any
15 questions from questions no. 1 to 21.

1. Which of the following options is/are not Python Keywords ? 1


(A) False
(B) Math
(C) WHILE
(D) break

2. Given the dictionary D={'Rno': 1, 'Name':'Suraj'} , write the output of


print(D('Name')). 1

3. Identify the statement(s) from the following options which will raise TypeError
exception(s) : 1
(A) print('5' * 3)
(B) print( 5 * 3)
(C) print('5' + 3)
(D) print('5' + '3')

91 Page 2
4. Identify the valid relational operator(s) in Python from the following : 1
(A) =
(B) <
(C) <>
(D) not

5. For a string S declared as S = 'PYTHON', which of the following is incorrect ? 1


(A) N=len(S)
(B) T = S
(C) 'T' in S
(D) S[0] = 'M'

6. Write a single line statement in Python to assign the values 'BLUE', 'GREEN', 'RED'
to a tuple named Colours. 1

7. A List is declared as L = ['ONE', 'TWO', 'THREE']


What will be the output of the statement ? 1
print(max(L))

8. Write the name of the built-in function/method of the math module which when
executed upon 5.8 as parameter, would return the nearest smaller integer 5. 1

9. In context of Communication Networks, which of the following is the correct expansion for
the abbreviation PAN : 1
(A) Prime Area Network
(B) Post Application Network
(C) Picture Application Network
(D) Personal Area Network

10. In context of Cyber Crimes and Cyber Thefts, the term IPR refers to : 1
(A) Internet Protocol Rights
(B) Inter Personnel Rights
(C) Intellectual Property Rights
(D) Individual Property Rights

11. In SQL, write the name of the aggregate function which will display the cardinality of a
table. 1

12. Which of the following clauses in SQL is most appropriate to use to select matching tuples
in a specific range of values ? 1
(A) IN
(B) LIKE
(C) BETWEEN
(D) IS

91 Page 3 P.T.O.
13. Which of the following is not a valid datatype in SQL ? 1
(A) DATE
(B) STRING
(C) DECIMAL
(D) CHAR

14. Which of the following is not a valid DML command in SQL ? 1


(A) INSERT
(B) UPDATE
(C) ALTER
(D) DELETE

15. Which of the following wireless transmission media is best suited for MAN ? 1
(A) Microwave
(B) Radio Link
(C) Infrared
(D) Bluetooth

16. Which of the following is/are immutable object type(s) in Python ? 1


(A) List
(B) String
(C) Tuple
(D) Dictionary

17. What shall be the ouput for the execution of the following Python Code ? 1
Cities = ['Delhi', 'Mumbai']
Cities[0], Cities[1] = Cities[1], Cities[0]
print(Cities)

18. Which of the following commands in SQL is used to add a new record into a table ? 1
(A) ADD
(B) INSERT
(C) UPDATE
(D) NEW

19. Which of the following is the correct expansion of DML in context of SQL ? 1
(A) Direct Machine Language
(B) Data Mixing Language
(C) Distributed Machine Language
(D) Data Manipulation Language

91 Page 4
20. Which of the following statements correctly explains the term Firewall in context of
Computer Network Society ? 1
(A) A device that protects the computer network from catching fire.
(B) A device/software that controls incoming and outgoing network traffic.
(C) Using abusive language on a social network site.
(D) Stea it as his/her own work.

21. Which of the following protocols allows the use of HTML on the World Wide Web ? 1
(A) HTTP
(B) PPP
(C) FTP
(D) POP
Section II
Both the case study-based questions are compulsory. Attempt any 4 sub-parts from each question.
Each question carries 1 mark.

22. Anmol maintains that database of Medicines for his pharmacy using SQL to store the
data. The structure of the table PHARMA for the purpose is as follows :
Name of the table - PHARMA
The attributes of PHARMA are as follows :
MID - numeric
MNAME - character of size 20
PRICE - numeric
UNITS - numeric
EXPIRY - date
Table : PHARMA

MID MNAME PRICE UNITS EXPIRY

M1 PARACETAMOL 12 120 2022-12-25

M2 CETRIZINE 6 125 2022-10-12

M3 METFORMIN 14 150 2022-05-23

M4 VITAMIN B-6 12 120 2022-07-01

M5 VITAMIN D3 25 150 2022-06-30

M6 TELMISARTAN 22 115 2022-02-25

(a) Write the degree and cardinality of the table PHARMA. 1

(b) Identify the attribute best suitable to be declared as a primary key. 1

91 Page 5 P.T.O.
(c) Anmol has received a new medicine to be added into his stock, but for which
he does not know the number of UNITS. So he decides to add the medicine
without its value for UNITS. The rest of the values are as follows :

MID MNAME PRICE EXPIRY


M7 SUCRALFATE 17 2022-03-20
Write the SQL command which Anmol should execute to perform the required
task. 1
(d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the
table PHARMA. Which of the following commands will he use for the
purpose ? 1
(i) UPDATE
(ii) DROP TABLE
(iii) CREATE TABLE
(iv) ALTER TABLE
(e) Now Anmol wants to increase the PRICE of all medicines by 5. Which of the
following commands will he use for the purpose ? 1
(i) UPDATE SET
(ii) INCREASE BY
(iii) ALTER TABLE
(iv) INSERT INTO
23. Roshni of Class 12 is writing a program in Python for her project work to create a CSV file
"Teachers.csv"
Number, Name for some entries. She has written the following code. However, she is
unable to figure out the correct statements in a few lines of the code, hence she has left
them blank. Help her to write the statements correctly for the missing parts in the code.
import _________ # Line 1
def addrec(Idno, Name): # to add record into the CSV file
f=open("Teachers.csv", _________) # Line 2
Filewriter = CSV.writer(f)
Filewriter.writerow([Idno,name])
f.close()
def readfile(): # to read the data from CSV file
f=open("Teachers.csv", ________) # Line 3
FileReader = CSV.________ (f) # Line 4
for row in FileReader:
print(row)
f._________ # Line 5

91 Page 6
(a) Name the module she will import in Line 1. 1
(b) In which mode will she open the file to add data into the file in Line 2 ? 1
(c) In which mode will she open the file to read the data from the file in Line 3 ? 1
(d) File in the blank in Line 4 to read the data from a CSV file. 1
(e) Fill in the blank in Line 5 to close the file. 1

PART B
Section I
24. Evaluate the following Python expressions : 2
(a) 2 * 3 + 4 ** 2 5 // 2

(b) 6 < 12 and not (20 > 15) or (10 > 5)


25. (a) What are cookies in a web browser ? Write one advantage and one disadvantage of
enabling cookies in a web browser. 2

OR

(b) Differentiate between the terms Domain Name and URL in context of web
services. Also write one example of each to illustrate the difference. 2
26. Expand the following terms in context of Computer Networks : 2
(a) PPP
(b) VoIP
(c) GSM
(d) WLL
27. (a) Explain the use of positional parameters in a Python function with the help of a
suitable example. 2

OR

(b) Explain the use of a default parameter in a Python function with the help of a
suitable example. 2
28. Rewrite the following code in Python after removing all syntax error(s) : 2
Underline each correction done in the code.

Runs = ( 10, 5, 0, 2, 4, 3 )
for I in Runs:
if I=0:
print(Maiden Over)
else
print(Not Maiden)

91 Page 7 P.T.O.
29. What possible output(s) is/are expected to be displayed on the screen at the time of
execution of the program from the following code ? Also specify the maximum and
minimum value that can be assigned to the variable R when K is assigned value as 2. 2

import random
Signal = [ 'Stop', 'Wait', 'Go' ]
for K in range(2, 0, 1):
R = randrange(K)
print (Signal[R], end = ' # ')

(a) Stop # Wait # Go #

(b) Wait # Stop #

(c) Go # Wait #

(d) Go # Stop #

30. What are Tuples in a SQL Table ? Write a suitable example with a SQL Table to
illustrate your answer. 2

31. For the following SQL Table named PASSENGERS in a database TRAVEL:

TNO NAME START END

T1 RAVI KUMAR DELHI MUMBAI

T2 NISHANT JAIN DELHI KOLKATA

T3 DEEPAK PRAKASH MUMBAI PUNE

A cursor named Cur is created in Python for a connection of a host which contains the
database TRAVEL. Write the output for the execution of the following Python statements
for the above SQL Table PASSENGERS: 2
Cur.execute('USE TRAVEL')
Cur.execute('SELECT * FROM PASSENGERS')
Recs=Cur.fetchall()
for R in Recs:
print(R[1])

32. Write the names of any two constraints and their respective uses in SQL. 2

91 Page 8
33. Write the output for the execution of the following Python code : 2

def change(A):

S=0
for i in range(len(A)//2):

S+=(A[i]*2)

return S

B = [10,11,12,30,32,34,35,38,40,2]

C = Change(B)

Print('Output is',C)

Section II

34. Write the definition of a function Sum3(L) in Python, which accepts a list L of integers
and displays the sum of all such integers from the list L which end with the digit 3. 3

For example, if the list L is passed


[ 123, 10, 13, 15, 23]

then the function should display the sum of 123, 13, 23, i.e. 159 as follows :
Sum of integers ending with digit 3 = 159

35. (a) Write the definition of a function ChangeGender() in Python, which reads the
contents of a text file "BIOPIC.TXT" and displays the content of the file with
every occurrence of the word 'he' replaced by 'she'. For example, if the
content of the file "BIOPIC.TXT" is as follows : 3
Last time he went to Agra,
there was too much crowd, which he did not like.
So this time he decided to visit some hill station.

The function should read the file content and display the output as follows :
Last time she went to Agra,
there was too much crowd, which she did not like.
So this time she decided to visit some hill station.

OR

91 Page 9 P.T.O.
(b) Write the definition of a function Count_Line() in Python, which should read
each line of a text file "SHIVAJI.TXT" and count total number of lines present in
text file. For example, if the content of the file "SHIVAJI.TXT" is as follows : 3

Shivaji was born in the family of Bhonsle.

He was devoted to his mother Jijabai.

India at that time was under Muslim rule.


The function should read the file content and display the output as follows :
Total number of lines : 3

36. Write the outputs of the SQL queries (i) to (iii) based on the relations CUSTOMER and
TRANSACTION given below : 3

Table : CUSTOMER

ACNO NAME GENDER BALANCE

C1 RISHABH M 15000

C2 AAKASH M 12500

C3 INDIRA F 9750

C4 TUSHAR M 14600

C5 ANKITA F 22000

Table : TRANSACTION

ACNO TDATE AMOUNT TYPE

C1 2020-07-21 1000 DEBIT

C5 2019-12-31 1500 CREDIT

C3 2020-01-01 2000 CREDIT

(i) SELECT MAX(BALANCE), MIN(BALANCE)FROM CUSTOMER


WHERE GENDER = 'M';
(ii) SELECT SUM(AMOUNT), TYPE FROM TRANSACTION
GROUP BY TYPE;
(iii) SELECT NAME, TDATE, AMOUNT
FROM CUSTOMER C, TRANSACTION T
WHERE C.ACNO = T.ACNO AND TYPE = 'CREDIT';

91 Page 10
37. (a) Write the definition of a function POP_PUSH(LPop, LPush, N) in Python. The
function should Pop out the last N elements of the list LPop and Push them into
the list LPush. For example : 3
If the contents of the list LPop are [10, 15, 20, 30]
And value of N passed is 2,
then the function should create the list LPush as [30, 20]
And the list LPop should now contain [10, 15]
NOTE : If the value of N is more than the number of elements present in
LPop, then display the message "Pop not possible".

OR
(b) Write a function in Python POPSTACK(L) where L is a stack implemented by a
list of numbers. The function returns the value deleted from the stack. 3

Section III
38. A school library is connecting computers in its units in a LAN. The library has 3 units as
shown in the diagram below : 5

The three units are providing the following services :


1. Teachers Unit : For access of the Library Books by teachers
2. Students Unit : For access of the Library Books by Students
3. Circulation Unit : For issue and return of books for teachers and students
Centre to Centre distances between the 3 units are as follows :
Circulation Unit to Teachers Unit 20 metres
Circulation Unit to Students Unit 30 metres
Teachers Unit to Students Unit 10 metres
Number of computers in each of the units is as follows :
Circulation Unit 15
Teachers Unit 10
Students Unit 10

91 Page 11 P.T.O.
(a) Suggest the most suitable place (i.e. the Unit name) to install the server of
this Library with a suitable reason.
(b) Suggest an ideal layout for connecting these Units for a wired connectivity.
(c) Which device will you suggest to be installed and where should it be placed to
provide Internet connectivity to all the Units ?
(d) Suggest the type of the most efficient and economical wired medium for
connecting all the computers in the network.
(e) The university is planni
computer which is in his office at a distance of 50 metres. Which type of
network out of LAN, MAN or WAN will be used for the network ? Justify your
answer.

39. Write SQL statements for the following queries (i) to (v) based on the relations
CUSTOMER and TRANSACTION given below : 5

Table : CUSTOMER

ACNO NAME GENDER BALANCE

C1 RISHABH M 15000

C2 AAKASH M 12500

C3 INDIRA F 9750

C4 TUSHAR M 14600

C5 ANKITA F 22000

Table : TRANSACTION

ACNO TDATE AMOUNT TYPE

C1 2020-07-21 1000 DEBIT

C5 2019-12-31 1500 CREDIT

C3 2020-01-01 2000 CREDIT

(a) To display all information about the CUSTOMERs whose NAME starts with
'A'.
(b) To display the NAME and BALANCE of Female CUSTOMERs (with GENDER as
'F') whose TRANSACTION Date (TDATE) is in the year 2019.
(c) To display the total number of CUSTOMERs for each GENDER.
(d) To display the CUSTOMER NAME and BALANCE in ascending order of GENDER.
(e) To display CUSTOMER NAME and their respective INTEREST for all
CUSTOMERs where INTEREST is calculated as 8% of BALANCE.

91 Page 12
40. (a) A binary file "PLANTS.dat" has structure (ID, NAME, PRICE).

Write the definition of a function WRITEREC() in Python, to input


data for records from the user and write them to the file
PLANTS.dat.

Write the definition of a function SHOWHIGH() in Python, which


reads the records of PLANTS.dat and displays those records for
which the PRICE is more than 500. 5
OR

(b) A binary file "PATIENTS.dat" has structure (PID, NAME, DISEASE).

Write the definition of a function countrec()in Python that would read contents
of the file "PATIENTS.dat" and display the details of those patients who have
the DISEASE as 'COVID-19'. The function should also display the total number
of such patients whose DISEASE is 'COVID-19'. 5

91 Page 13 P.T.O.
SET-4
Series %BAB%/C
Q.P. Code
91

Roll No. Candidates must write the Q.P. Code on


the title page of the answer-book.

Please check that this question paper contains 9 printed pages.


Q.P. Code given on the right hand side of the question paper should be written
on the title page of the answer-book by the candidate.
Please check that this question paper contains 13 questions.
Please write down the serial number of the question in the
answer-book before attempting it.
15 minute time has been allotted to read this question paper. The question
paper will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the
students will read the question paper only and will not write any answer on
the answer-book during this period.

COMPUTER SCIENCE

Time allowed : 2 hours Maximum Marks : 35


General Instructions :
(i) This question paper is divided into 3 sections A, B and C.
(ii) Section A, consists 7 questions (1 7). Each question carries 2 marks.
(iii) Section B, consists 3 questions (8 10). Each question carries 3 marks.
(iv) Section C, consists 3 questions (11 13). Each question carries 4 marks.
(v) Internal choices have been given for questions number 7, 8 and 12.

91 Page 1 P.T.O.
SECTION A
(Each question carries 2 marks)

1. Differentiate between Push and Pop operations in the context of stacks. 2

2. (a) Expand FTP. 1

(b) Out of the following, which has the largest network coverage area ? 1

LAN, MAN, PAN, WAN

3. Differentiate between Degree and Cardinality in the context of Relational


Data Model. 2

4. Consider the following table EMPLOYEE in a Database COMPANY :


Table : EMPLOYEE
E_ID NAME DEPT
H1001 Avneet AC
A1002 Rakesh HR
A1003 Amina AC
H1002 Simon HR
A1004 Pratik AC

Assume that the required library for establishing the connection between
Python and MySQL is already imported in the given Python code.
Also assume that DB is the name of the database connection for the given
table EMPLOYEE stored in the database COMPANY.

Predict the output of the following Python code : 2


CUR=DB.cursor()
CUR.execute("USE COMPANY")
CUR.execute("SELECT * FROM EMPLOYEE WHERE DEPT = 'AC' ")
for i in range(2) :
R=CUR.fetchone()
print(R[0], R[1], sep ="#")

91 Page 2
5. Write the output of the SQL queries (a) to (d) based on the table TRAVEL
given below : 2
Table : TRAVEL
T_ID START END T_DATE FARE
101 DELHI CHENNAI 2021-12-25 4500
102 DELHI BENGALURU 2021-11-20 4000
103 MUMBAI CHENNAI 2020-12-10 5500
104 DELHI MUMBAI 2019-12-20 4500
105 MUMBAI BENGALURU 2022-01-15 5000

(a) SELECT START, END FROM TRAVEL


WHERE FARE <= 4000 ;

(b) SELECT T_ID, FARE FROM TRAVEL


WHERE T_DATE LIKE '2021-12-%' ;

(c) SELECT T_ID, T_DATE FROM TRAVEL WHERE END = 'CHENNAI'


ORDER BY FARE ;

(d) SELECT START, MIN(FARE)


FROM TRAVEL GROUP BY START ;

6. Write the output of the SQL queries (a) and (b) based on the following two
tables FLIGHT and PASSENGER belonging to the same database : 2
Table : FLIGHT
FNO DEPART ARRIVE FARE
F101 DELHI CHENNAI 4500
F102 DELHI BENGALURU 4000
F103 MUMBAI CHENNAI 5500
F104 DELHI MUMBAI 4500
F105 MUMBAI BENGALURU 5000

91 Page 3 P.T.O.
Table : PASSENGER
PNO NAME FLIGHTDATE FNO
P1 PRAKASH 2021-12-25 F101
P2 NOOR 2021-11-20 F103
P3 HARMEET 2020-12-10 NULL
P4 ANNIE 2019-12-20 F105

(a) SELECT NAME, DEPART FROM FLIGHT


NATURAL JOIN PASSENGER ;

(b) SELECT NAME, FARE


FROM PASSENGER P, FLIGHT F
WHERE F.FNO = P.FNO AND F.DEPART = 'MUMBAI' ;

7. (a) Explain Primary Key in the context of Relational Database Model.


Support your answer with suitable example. 2

OR

(b) Consider the following table BATSMEN :


Table : BATSMEN
PNO NAME SCORE
P1 RISHABH 52
P2 HUSSAIN 45
P3 ARNOLD 23
P4 ARNAV 18
P5 GURSHARAN 52

(i) Identify and write the name of the Candidate Keys in the
given table BATSMEN.

(ii) How many tuples are there in the given table BATSMEN ? 2

91 Page 4
SECTION B
(Each question carries 3 marks)

8. (a) Write separate user defined functions for the following : 3


(i) PUSH(N) This function accepts a list of names, N as parameter.
It then pushes only those names in the stack named OnlyA
which contain the letter 'A'.
(ii) POPA(OnlyA) This function pops each name from the stack
OnlyA and displays it. When the stack is empty, the message
"EMPTY" is displayed.
For example :
If the names in the list N are
['ANKITA', 'NITISH', 'ANWAR', 'DIMPLE', 'HARKIRAT']
Then the stack OnlyA should store
['ANKITA', 'ANWAR', 'HARKIRAT']
And the output should be displayed as
HARKIRAT ANWAR ANKITA EMPTY
OR
(b) Write the following user defined functions : 3
(i) pushEven(N) This function accepts a list of integers named N
as parameter. It then pushes only even numbers into the stack
named EVEN.
(ii) popEven(EVEN) This function pops each integer from the
stack EVEN and displays the popped value. When the stack is
empty, the message "Stack Empty" is displayed.
For example :
If the list N contains
[10,5,3,8,15,4]
Then the stack, EVEN should store
[10,8,4]
And the output should be
4 8 10 Stack Empty

91 Page 5 P.T.O.
9. (a) A SQL table BOOKS contains the following column names :
BOOKNO, BOOKNAME, QUANTITY, PRICE, AUTHOR
Write the SQL statement to add a new column REVIEW to store the
reviews of the book. 1
(b) Write the names of any two commands of DDL and any two
commands of DML in SQL. 2

10. Rashmi has forgotten the names of the databases, tables and the structure
of the tables that she had created in Relational Database Management
System (RDBMS) on her computer.
(a) Write the SQL statement to display the names of all the databases
present in RDBMS application on her computer.
(b) Write the statement which she should execute to open the database
named "STOCK".
(c) Write the statement which she should execute to display the
structure of the table "ITEMS" existing in the above opened
database "STOCK". 3

SECTION C
(Each question carries 4 marks)

11. Write SQL queries for (a) to (d) based on the tables CUSTOMER and
TRANSACT given below : 4
Table : CUSTOMER
CNO NAME GENDER ADDRESS PHONE
1001 Suresh MALE A-123, West Street 9310010010
1002 Anita FEMALE C-24, Court Lane 9121211212
1003 Harjas MALE T-1, Woods Avenue 9820021001

Table : TRANSACT
TNO CNO AMOUNT TTYPE TDATE
T1 1002 2000 DEBIT 2021-09-25
T2 1003 1500 CREDIT 2022-01-28
T3 1002 3500 CREDIT 2021-12-31
T4 1001 1000 DEBIT 2022-01-10

91 Page 6
(a) Write the SQL statements to delete the records from table
TRANSACT whose amount is less than 1000.

(b) Write a query to display the total AMOUNT of all DEBITs and all
CREDITs.

(c) Write a query to display the NAME and corresponding AMOUNT of all
CUSTOMERs who made a transaction type (TTYPE) of CREDIT.

(d) Write the SQL statement to change the Phone number of customer
whose CNO is 1002 to 9988117700 in the table CUSTOMER.

12. (a) (i) Mention any two characteristics of BUS Topology. 2

OR

(ii) Differentiate between the terms Domain Name and URL in


the context of World Wide Web. 2

(b) Write the names of two wired and two wireless data transmission
mediums. 2

13. The government has planned to develop digital awareness in the rural
areas of the nation. According to the plan, an initiative is taken to set up
Digital Training Centers in villages across the country with its Head
Office in the nearest cities. The committee has hired a networking
consultancy to create a model of the network in which each City Head
Office is connected to the Training Centers situated in 3 nearby villages.

As a network expert in the consultancy, you have to suggest the best


network-related solutions for the issues/problems raised in (a) to (d),
keeping in mind the distance between various locations and other given
parameters. 4
91 Page 7 P.T.O.
Layout of the City Head Office and Village Training Centers :

City Head Village 1


Training
Office Center

Village 3
Training
Village 2 Center
Training
Center

Shortest distances between various Centers :

Village 1 Training Center to City Head Office 2 KM

Village 2 Training Center to City Head Office 1·5 KM

Village 3 Training Center to City Head Office 3 KM

Village 1 Training Center to Village 2 Training Center 3·5 KM

Village 1 Training Center to Village 3 Training Center 4·5 KM

Village 2 Training Center to Village 3 Training Center 3·5 KM

Number of Computers installed at various centers are as follows :

Village 1 Training Center 10

Village 2 Training Center 15

Village 3 Training Center 15

City Head Office 100

91 Page 8
(a) It is observed that there is a huge data loss during the process of
data transfer from one village to another. Suggest the most
appropriate networking device out of the following, which needs to
be placed along the path of the wire connecting one village with
another to refresh the signal and forward it ahead.
(i) MODEM
(ii) ETHERNET CARD
(iii) REPEATER
(iv) HUB

(b) Draw the cable layout (location-to-location) to efficiently connect


various Village Training Centers and the City Head Office for the
above shown layout.

(c) Which hardware networking device, out of the following, will you
suggest to connect all the computers within the premises of every
Village Training Center ?

(i) SWITCH
(ii) MODEM
(iii) REPEATER
(iv) ROUTER

(d) Which protocol, out of the following, will be most helpful to conduct
online interactions of Experts from the City Head Office and people
at the three Village Training Centers ?
(i) FTP
(ii) PPP

(iii) SMTP
(iv) VoIP

91 Page 9 P.T.O.
Series HEFG/C Set-4
Q.P. Code 91

Roll No.

COMPUTER SCIENCE (NEW)


Time allowed : 3 hours Maximum Marks : 70

Please check that this question paper contains 19 printed pages.


Q.P. Code given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.
Please check that this question paper contains 35 questions.
Please write down the serial number of the question in the
answer-book before attempting it.
15 minute time has been allotted to read this question paper. The
question paper will be distributed at 10.15 a.m. From 10.15 a.m. to
10.30 a.m., the students will read the question paper only and will not
write any answer on the answer-book during this period.

$*
General Instructions :
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A has 18 questions carrying 1 mark each.
Section B has 7 Very Short Answer (VSA) type questions carrying 2 marks each.
Section C has 5 Short Answer (SA) type questions carrying 3 marks each.
Section D has 3 Long Answer (LA) type question carrying 5 marks each.
Section E has 2 questions carrying 4 marks each. One internal choice is given
in Q 35 against part C only.
All programming questions are to be answered using Python Language only.
91 ^ Page 1 of 19 P.T.O.
SECTION A

All questions carrying 1 mark each. 18 1=18

1. State True or False.

2. Which of the following is not a sequential datatype in Python ?

(a) Dictionary
(b) String

(c) List

(d) Tuple

3. Given the following dictionary


Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}
Which statement will return "Tuesday".

(a) Day.pop()
(b) Day.pop(2)

(c) Day.pop(1)
(d) Day.pop("Tuesday")

4. Consider the given expression :


7<4 or 6>3 and not 10==10 or 17>4
Which of the following will be the correct output if the given expression is
evaluated ?
(a) True
(b) False

(c) NONE
(d) NULL

91 Page 2 of 19
5. Select the correct output of the code :
S="Amrit Mahotsav @ 75"
A=S.split(" ",2)
print(A)
(a) ('Amrit', 'Mahotsav', '@', '75')
(b) ['Amrit', 'Mahotsav', '@ 75']
(c) ('Amrit', 'Mahotsav', '@ 75')
(d) ['Amrit', 'Mahotsav', '@', '75']

6. Which of the following modes in Python creates a new file, if file does not
exist and overwrites the content, if the file exists ?
(a) r+ (b) r
(c) w (d) a

7. Fill in the blank :


___________ is not a valid built-in function for list manipulations.
(a) count()
(b) length()
(c) append()
(d) extend()

8. Which of the following is an example of identity operators of Python ?


(a) is (b) on
(c) in (d) not in

9. Which of the following statement(s) would give an error after executing


the following code ?
S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S) # Statement 5
(a) Statement 2 (b) Statement 3
(c) Statement 4 (d) Statement 3 and 4
91 Page 3 of 19 P.T.O.
10. Fill in the blank :
In a relational model, tables are called _________, that store data for
different columns.
(a) Attributes
(b) Degrees
(c) Relations
(d) Tuples

11. The correct syntax of tell() is :


(a) tell.file_object()
(b) file_object.tell()
(c) tell.file_object(1)
(d) file_object.tell(1)

12. Fill in the blank :


_________ statement of SQL is used to insert new records in a table.
(a) ALTER
(b) UPDATE
(c) INSERT
(d) CREATE

13. Fill in the blank :


In _________ switching, before a communication starts, a dedicated path
is identified between the sender and the receiver.
(a) Packet
(b) Graph
(c) Circuit
(d) Plot

91 Page 4 of 19
14. What will the following expression be evaluated to in Python ?
print(6/3 + 4**3//8 4)
(a) 6.5
(b) 4.0
(c) 6.0
(d) 4

15. Which of the following functions is a valid built-in function for both list
and dictionary datatype ?
(a) items()
(b) len()
(c) update()
(d) values()

16. fetchone() method fetches only one row in a ResultSet and returns a
__________.
(a) Tuple
(b) List
(c) Dictionary
(d) String

Q. 17 and 18 are Assertion (A) and Reasoning (R) based questions. Mark
the correct choice as

(a) Both (A) and (R) are true and (R) is the correct explanation for (A).

(b) Both (A) and (R) are true and (R) is not the correct explanation for
(A).

(c) (A) is true but (R) is false.

(d) (A) is false but (R) is true.


91 Page 5 of 19 P.T.O.
17. Assertion (A) : In Python, a stack can be implemented using a list.
Reasoning (R) : A stack is an ordered linear list of elements that works
on the principle of First In First Out (FIFO).

18. Assertion (A) : readlines() reads all the lines from a text file and
returns the lines along with newline as a list of strings.
Reasoning (R) : readline() can read the entire text file line by line
without using any looping statements.

SECTION B

19. Ravi, a Python programmer, is working on a project in which he wants to


write a function to count the number of even and odd values in the list.
He has written the following code but his code is having errors. Rewrite
the correct code and underline the corrections made. 2
define EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
Else:
odd_no+=1
print(even_no, odd_no)

20. (a) Write any two differences between Fiber-optic cable and Coaxial
cable. 2

OR

(b) Write one advantage and one disadvantage of wired over wireless
communication. 2

91 Page 6 of 19
21. (a) Given is a Python string declaration : 1
NAME = "Learning Python is Fun"
Write the output of : print(NAME[-5:-10:-1])

(b) Write the output of the code given below : 1


dict1={1:["Rohit",20], 2:["Siya",90]}
dict2={1:["Rahul",95], 5:["Rajan",80]}
dict1.update(dict2)
print(dict1.values())

22. Explain the usage of HAVING clause in GROUP BY command in RDBMS


with the help of an example. 2

23. (a) Write the full forms of the following : 1


(i) XML
(ii) HTTPS

(b) What is the use of FTP ? 1

24. (a) Write the output of the Python code given below : 2
g=0
def fun1(x,y):
global g
g=x+y
return g
def fun2(m,n):
global g
g=m-n
return g
k=fun1(2,3)
fun2(k,7)
print(g)

OR

91 Page 7 of 19 P.T.O.
(b) Write the output of the Python code given below : 2
a=15
def update(x):
global a
a+=2
if x%2==0:
a*=x
else:
a//=x
a=a+5
print(a,end="$")
update(5)
print(a)

25. (a) Differentiate between IN and BETWEEN operators in SQL with


appropriate examples. 2
OR
(b) Which of the following is NOT a DML command. 2
DELETE, DROP, INSERT, UPDATE

SECTION C

26. (a) Consider the following tables Student and Sport :


Table : Student
ADMNO NAME CLASS
1100 MEENA X
1101 VANI XI

Table : Sport
ADMNO GAME
1100 CRICKET
1103 FOOTBALL

What will be the output of the following statement ? 1


SELECT * FROM Student, Sport;

91 Page 8 of 19
(b) Write the output of the queries (i) to (iv) based on the table,
GARMENT given below : 2

TABLE : GARMENT
GCODE TYPE PRICE FCODE ODR_DATE
G101 EVENING GOWN 850 F03 2008-12-19
G102 SLACKS 750 F02 2020-10-20
G103 FROCK 1000 F01 2021-09-09
G104 TULIP SKIRT 1550 F01 2021-08-10
G105 BABY TOP 1500 F02 2020-03-31
G106 FORMAL PANT 1250 F01 2019-01-06

(i) SELECT DISTINCT(COUNT(FCODE))FROM GARMENT;

(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM


GARMENT GROUP BY FCODE HAVING COUNT(*)>1;

(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE


>'2021-02-01' AND PRICE <1500;

(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';

27. (a) Write a function in Python that displays the book names having
y in their name from a text file Bookname.t 3
Example :
s the names of following books :

One Hundred Years of Solitude


The Diary of a Young Girl
On the Road

After execution, the output will be :

One Hundred Years of Solitude


The Diary of a Young Girl

OR

91 Page 9 of 19 P.T.O.
(b) Write a function RevString()
prints the words The rest of the
content is displayed normally. 3
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM

28. Write the output of any three SQL queries (i) to (iv) based on the tables
COMPANY and CUSTOMER given below : 3

Table : COMPANY
CID C_NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY CHENNAI MOBILE
666 DELL DELHI LAPTOP

Table : CUSTOMER
CUSTID CID NAME PRICE QTY
C01 222 ROHIT SHARMA 70000 20
C02 666 DEEPIKA KUMARI 50000 10
C03 111 MOHAN KUMAR 30000 5
C04 555 RADHA MOHAN 30000 11

(i) SELECT PRODUCTNAME, COUNT(*)FROM COMPANY GROUP BY


PRODUCTNAME HAVING COUNT(*)> 2;
(ii) SELECT NAME, PRICE, PRODUCTNAME FROM COMPANY C,
CUSTOMER CT WHERE C.CID = CU.CID AND C_NAME = 'SONY';
(iii) SELECT DISTINCT CITY FROM COMPANY;
(iv) SELECT * FROM COMPANY WHERE C_NAME LIKE '%ON%';

91 Page 10 of 19
29. Write a function search_replace() in Python which accepts a list L of
numbers and a number to be searched. If the number exists, it is replaced
by 0 and if the number does not exist, an appropriate message is
displayed. 3
Example :
L = [10,20,30,10,40]
Number to be searched = 10

List after replacement :


L = [0,20,30,0,40]

30. A list contains following record of course details for a University :


[Course_name, Fees, Duration]

Write the following user defined functions to perform given operations on


the stack named 'Univ' : 3
(i) Push_element() To push an object containing the
Course_name, Fees and Duration of a course, which has fees
greater than 100000 to the stack.

(ii) Pop_element() To pop the object from the stack and display it.

For example :
If the lists of courses details are :

3]
2]

3]

The stack should contain :

2]
3]
91 Page 11 of 19 P.T.O.
SECTION D

31. ABC Consultants are setting up a secure network for their office campus
at Noida for their day-to-day office and web-based activities. They are
planning to have connectivity between three buildings and the head office
situated in Bengaluru. As a network consultant, give solutions to the
questions (i) to (v), after going through the building locations and other
details which are given below :

NOIDA BRANCH BENGALURU BRANCH

BUILDING 1 HEAD OFFICE


BUILDING 2

BUILDING 3

Distance between various blocks/locations :


Building Distance
Building 1 to Building 3 120 m
Building 1 to Building 2 50 m
Building 2 to Building 3 65 m
Noida Branch to Head Office 1500 km

Number of computers
Building Number of Computers
Building 1 25
Building 2 51
Building 3 150
Head Office 10
(i) Suggest the most suitable place to install the server for this
organization. Also, give reason to justify your suggested location. 1
(ii) Suggest the cable layout of connections between the buildings
inside the campus. 1

91 Page 12 of 19
(iii) Suggest the placement of the following devices with justification : 1
Switch
Repeater

(iv) The organization is planning to provide a high-speed link with the


head office situated in Bengaluru, using a wired connection.
Suggest a suitable wired medium for the same. 1

(v) The System Administrator does remote login to any PC, if any
requirement arises. Name the protocol, which is used for the same. 1

32. (a) (i) What possible output(s) are expected to be displayed on


screen at the time of execution of the following code ? 2

import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)

print(S[f],S[s],sep=":")

Options :
(I) Pencil:Book

(II) Pencil:Book
Eraser:Bag

(III) Pen:Book
Bag:Book

(IV) Bag:Eraser

91 Page 13 of 19 P.T.O.
(ii) The table Bookshop in MySQL contains the following
attributes :
B_code Integer
B_name String
Qty Integer
Price Integer

Note the following to establish connectivity between Python


and MySQL o :
Username is shop
Password is Book
The table exists in a MySQL database named
Bstore.
The code given below updates the records from the table
Bookshop in MySQL. 3
Statement 1 to form the cursor object.
Statement 2 to execute the query that updates the Qty to
20 of the records whose B_code is 105 in the table.
Statement 3 to make the changes permanent in the
database.

import mysql.connector as mysql


def update_book():

mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=__________ # Statement 1
qry= "update Bookshop set Qty=20 where
B_code=105"
___________________ # Statement 2
___________________ # Statement 3

OR

91 Page 14 of 19
(b) (i) Predict the output of the code given below : 2
text="LearningCS"
L=len(text)
ntext=""
for i in range (0,L):
if text[i].islower():
ntext=ntext+text[i].upper()
elif text [i].isalnum():
ntext=ntext+text[i 1]
else:
ntext=ntext+'&&'
print(ntext)

(ii) The table Bookshop in MySQL contains the following


attributes :
B_code Integer
B_name String
Qty Integer
Price Integer

Note the following to establish connectivity between Python


and MySQL o :
Username is shop
Password is Book
The table exists in a MySQL database named
Bstore.
The code given below reads the records from the table
Bookshop and displays all the records : 3
Statement 1 to form the cursor object.
Statement 2 to write the query to display all the records
from the table.

91 Page 15 of 19 P.T.O.
Statement 3 to read the complete result of the query into
the object named B_Details, from the table Bookshop in
the database.

import mysql.connector as mysql


def Display_book():

mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=___________ # Statement 1
mycursor.execute("_________") # Statement 2
B_Details=__________ # Statement 3
for i in B_Details:

print(i)

33. (a) Write a point of difference between append (a) and write (w)
modes in a text file. 5
Write a program in Python that defines and calls the following
user defined functions :
(i) Add_Teacher() : It accepts the values from the user and
inserts
record consists of a list with field elements as T_id, Tname
and desig to store teacher ID, teacher name and
designation respectively.
(ii) Search_Teacher() : To display the records of all the PGT
(designation) teachers.
OR
(b) Write one point of difference between seek() and tell()
functions in file handling. Write a program in Python that defines
and calls the following user defined functions : 5
(i) Add_Device() : The function accepts and adds records of the

consists of a list with field elements as P_id, P_name and


Price to store peripheral device ID, device name, and price
respectively.
(ii) Count_Device() : To count and display number of peripheral
devices, whose price is less than < 1000.

91 Page 16 of 19
SECTION E

34. The ABC Company is considering to maintain their salespersons records


using SQL to store data. As a database administrator, Alia created the
table Salesperson and also entered the data of 5 Salespersons.

Table : Salesperson
S_ID S_NAME AGE S_AMOUNT REGION
S001 SHYAM 35 20000 NORTH
S002 RISHABH 30 25000 EAST
S003 SUNIL 29 21000 NORTH
S004 RAHIL 39 22000 WEST
S005 AMIT 40 23000 EAST

Based on the data given above, answer the following questions :


(i) Identify the attribute that is best suited to be the Primary Key and
why ? 1
(ii) The Company has asked Alia to add another attribute in the table.
What will be the new degree and cardinality of the above table ? 1
(iii) Write the statements to : 2
(a) Insert details of one salesman with appropriate data.
(b) SHYAM SOUTH
table Salesperson.

OR (Option for part iii only)

(iii) Write the statement to : 2


(a) Delete the record of salesman RISHABH, as he has left the
company.
(b) Remove an attribute REGION from the table.

91 Page 17 of 19 P.T.O.
35. Atharva is a programmer, who has recently been given a task to write a
Python code to perform the following binary file operation with the help
of a user defined function/module :

Copy_new() : to create a binary file new_items.dat and write all

the item details stored in the binary file, items.dat, except for

the item whose item_id is 101. The data is stored in the following
format :
{item_id:[item_name,amount]}

import ___________ # Statement 1

def Copy_new():

f1=_____________ # Statement 2

f2=_____________ # Statement 3

item_id=int(input("Enter the item id"))

item_detail=___________ # Statement 4

for key in item_detail:

if _______________: # Statement 5

pickle.___________ # Statement 6

f1.close()

f2.close()

He has succeeded in writing partial code and has missed out certain
statements. Therefore, as a Python expert, help him to complete the code

based on the given requirements :

91 Page 18 of 19
(i) Which module should be imported in the program ? (Statement 1) 1

(ii) Write the correct statement required to open the binary file
"items.dat". (Statement 2) 1

(iii) Which statement should Atharva fill in Statement 3 to open the


binary file "new_items.dat" and in Statement 4 to read all the
details from the binary file "items.dat". 2

OR (Option for part iii only)

(iii) What should Atharva write in Statement 5 to apply the given


condition and in Statement 6 to write data in the binary file
"new_items.dat". 2

91 Page 19 of 19 P.T.O.

You might also like