0% found this document useful (0 votes)
7 views43 pages

MS_Computer_Sscience_283_old

This pdf is of a cs book named ms

Uploaded by

pranavaryan0724
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views43 pages

MS_Computer_Sscience_283_old

This pdf is of a cs book named ms

Uploaded by

pranavaryan0724
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Strictly Confidential: (For Internal and Restricted use only)

Senior School Certificate Examination


September 2021
Marking Scheme – Computer Science (OLD) (SUBJECT CODE: 283)
(SET: 4 | SERIES: 3HKP35/C| CODE NO –491 )
General Instructions:
1. You are aware that evaluation is the most important process in the actual and correct assessment of
the candidates. A small mistake in evaluation may lead to serious problems which may affect the
future of the candidates, education system and the teaching profession. To avoid mistakes, it is
requested that before starting evaluation, you must read and understand the spot evaluation
guidelines carefully. Evaluation is a 10 -12 days mission for all of us. Hence, it is necessary that you
put in your best efforts in this process.
2. Evaluation is to be done as per instructions provided in the Marking Scheme. It should not be done
according to one’s own interpretation or any other consideration. Marking Scheme should be strictly
adhered to and religiously followed. However, while evaluating answers which are based on the
latest information or knowledge and/or are innovative, they may be assessed for their correctness
otherwise and marks be awarded to them.
3. The Head-Examiner must go through the first five answer books evaluated by each evaluator on the
first day, to ensure that evaluation has been carried out as per the instructions given in the Marking
Scheme. The remaining answer books meant for evaluation shall be given only after ensuring that
there is no significant variation in the marking of individual evaluators.
4. If a question has parts, please award marks on the right-hand side for each part. Marks awarded for
different parts of the question should then be totaled up and written in the left-hand margin and
encircled.
5. If a question does not have any parts, marks must be awarded in the left hand margin and encircled.
6. If a student has attempted an extra question, the answer of the question deserving more marks should
be retained and the other answer scored out.
7. No marks to be deducted for the cumulative effect of an error. It should be penalized only once.
8. A full scale of marks 70 (example: 1-70) has to be used. Please do not hesitate to award full marks if
the answer deserves it.
9. Every examiner has to necessarily do evaluation work for full working hours i.e. 8 hours every day and
evaluate 25 answer books per day.
10. Ensure that you do not make the following common types of errors committed by the Examiner in the
past:-
a. Leaving the answer or part thereof unassessed in an answer book.
b. Giving more marks for an answer than assigned to it.
c. Wrong transfer of marks from the inside pages of the answer book to the title page.
d. Wrong question wise totaling on the title page.
e. Wrong totaling of marks of the two columns on the title page.
f. Wrong grand total.
g. Marks in words and figures not tallying.
h. Wrong transfer of marks from the answer book to online award list.
i. Answers marked as correct, but marks not awarded. (Ensure that the right tick mark is correctly
and clearly indicated. It should merely be a line. Same is with the X for incorrect answers.)
j. Half or a part of the answer marked correct and the rest as wrong, but no marks awarded.
11. While evaluating the answer books, if the answer is found to be totally incorrect, it should be marked
as (X) and awarded zero (0) Marks.
12. Any unassessed portion, non-carrying over of marks to the title page, or totaling error detected by the
candidate shall damage the prestige of all the personnel engaged in the evaluation work as also of the
Board. Hence, in order to uphold the prestige of all concerned, it is again reiterated that the
instructions be followed meticulously and judiciously.
13. The Examiners should acquaint themselves with the guidelines given in the Guidelines for spot
Evaluation before starting the actual evaluation.
14. Every Examiner shall also ensure that all the answers are evaluated, marks carried over to the title
page, correctly totaled and written in figures and words.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #1/43]


15. The Board permits candidates to obtain a photocopy of the Answer Book on request in an RTI
application and also separately as a part of the re-evaluation process on payment of the processing
charges.

Specific Instructions:
● All programming questions have to be answered with respect to C++ Language / Python only
● In C++ / Python, ignore case sensitivity for identifiers (Variable / Functions / Structures / Class
Names)
● In Python indentation is mandatory, however, the number of spaces used for indenting may vary
● In SQL related questions – both ways of text/character entries should be acceptable for Example:
“AMAR” and ‘amar’ both are acceptable.
● In SQL related questions – all date entries should be acceptable for Example: ‘YYYY-MM-DD’,
‘YY-MM-DD’, ‘DD-Mon-YY’, “DD/MM/YY”, ‘DD/MM/YY’, “MM/DD/YY”, ‘MM/DD/YY’ and {MM/DD/YY}
are correct.
● In SQL related questions – semicolon should be ignored for terminating the SQL statements
● In SQL related questions, ignore case sensitivity.

SECTION A - (Only for candidates, who opted for C++)

Q. No Part Question Description Marks

1 (a) Write the type of C++ Operators (Arithmetic, Relational or Logical Operators) 2
from the following :
(i) ||
(ii) <=
(iii) %
(iv) *
Ans (i) || - Logical
(ii) <= - Relational
(iii) % - Arithmetic
(iv) * - Arithmetic
(½ mark for each correct answer)

(b) Write the names of the correct header files, which must be included in the 1
following C++ code to compile the code successfully :

void main()
{
char STR[]="india2020";
STR[0]=toupper(STR[0]);
puts(STR);
}

Ans stdio.h
ctype.h

(½ mark for each of the two correct header files)

(c) Rewrite the following C++ program after removing any/all syntactical errors 2
with each correction underlined :

Note : Assume all required header files are already included in the program.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #2/43]


Typedef float REAL;
void main()
{
REAL Pie=3.1416,R,AREA;
cin<<R;
AREA=Pie*R*R;
cout>>'Area:'>>AREA>>endl;
}

Ans typedef float REAL; //Error1


void main()
{
REAL Pie=3.1416,R,AREA;
cin>>R; //Error2
AREA=Pie*R*R;
cout<<"Area:"<<AREA<<endl; //Error3 and Error4
}

(½ mark for each of the 4 corrections)


(Deduct ½ mark if the corrections are done correctly but not underlined)

(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 Manip(char S[])


{
for(int I=0;S[I]!='\0'; I++)
if (I%2 == 0)
if (S[I]>='A' && S[I]<='M')
S[I]=tolower(S[I]);
else
S[I]='#';
else
if (S[I]>='N' && S[I]<='Z')
S[I]='*';
else
S[I]=S[I]+1;
}
void main()
{
char TXT[]="CaNW2GeT";
Manip(TXT);
cout<<TXT<<endl;
}

Ans cb#*#H#*

(½ mark for writing first 2 characters of the output as cb correctly)


(½ mark for writing next 2 characters of the output as #* correctly)
(½ mark for writing next 2 characters of the output as #H correctly)
(½ mark for writing last 2 characters of the output as #* correctly)

(e) Find and write the output of the following C++ program code : 3
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #3/43]
Note : Assume all required header files are already included in the program.

void Exchange (int &A, int B=2)


{
A+=B;
B=A-B;
cout<<2*A<<"@"<<4*B<<endl;
}
void main()
{
int P=100, Q=50;
Exchange(Q);
Exchange(P,Q);
Exchange(P);
}

Ans 104@200
304@400
308@608

(½ mark for each of the six correct output values)


(Deduct only ½ mark if the output values are correctly written without '@'
and line break)

(f) Look at the following C++ code and find which output(s) from the options (i) to 2
(iv) is/are not possible. Also, write the minimum and maximum values that can
possibly be assigned to the variable Val.

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[4],Val;
for(int I=3; I>=0; I--)
{
Val = random(2+I) + 11;
A[I]=Val;
}
for (I=0;I<4;I++)
cout<<A[I]<<"@";
}

(i) 12@11@11@14@ (ii) 10@13@14@13@

(iii) 12@11@13@14@ (iv) 11@13@12@13@

Ans (ii) 10@13@14@13@

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #4/43]


Maximum possible value for Val = 15
Minimum possible value for Val = 11

(1 mark for writing the correct option)


(½ mark each for the maximum and minimum value of Val)

2. (a) Given the following class Packer and assuming all necessary header file(s)
included, answer the questions that follow the code:
class Packer
{
int PID; float WT;
public:
Packer(int ID) //Function 1
{
PID = ID;
}
Packer() //Function 2
{
PID = 1001;
WT = 100;
}
Packer(Packer &P) //Function 3
{
PID = P.PID + 1;
WT = P.WT + 10;
}
Packer(float W) //Function 4
{
WT = W;
}
Packer(int ID, float W) //Function 5
{
PID = ID;
WT = W;
}
};
void main()
{
Packer P1; //Statement I
Packer P2(70); //Statement II
__________; //Statement III
}

(i) Which function out of 1, 2, 3, 4 and 5 is a Copy Constructor and which one is a 1
default constructor in the definition of class Packer ?

Ans Function 3 - Copy Constructor


Function 2 - Default Constructor

(½ mark each for identifying Copy and Default constructors correctly)

(ii) Write the Statement III, to declare an object P3 of class Packer with two 1
parameters 75 and 32.5.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #5/43]


Ans Packer P3(75,32.5)
OR
Packer P3=Packer(75,32.5)

(1 mark for writing the correct declaration of the object)

(b) Observe the following C++ code and answer the questions (i) and (ii).

Note : Assume all necessary files are included.


class Store
{
int SID;
public:
Store(int ID=10) //Function 1
{
SID=ID;
cout<<"Store"<<SID<<"Opened"<<endl;
}
~Store() //Function 2
{
cout<<"Store Closed"<<endl;
}
void Display() //Function 3
{
cout<<"Store "<<SID<<" is Active"<<endl;
}
};
void main()
{
Store S(25);
S.Display();
}

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

Ans Store25Opened
Store 25 is Active
Store Closed

( 1 mark for writing complete output)


OR
( ½ mark for writing any one line of correct output)

(ii) For the class Store, what is Function 2 known as ? When does this function get 1
executed ?

Ans Destructor
Function 2 gets executed when the object goes out off scope.
(½ mark for correctly writing Destructor)
(½ mark for writing the correct answer of the second part)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #6/43]


OR

(b) Explain Copy Constructor in context of Object Oriented Programming. 2


Also give a supporting example in C++.

Ans A copy constructor is an overloaded constructor in which an object of the same


class is passed as a reference parameter.

class Point
{ int x;
public:
point() {x=0;}
point(Point &P) // Copy Constructor
{ x=P.x;}
.
.
.
};
( 1 mark for correctly defining copy constructor)
( 1 mark for example of copy constructor)
OR
( 2 mark for correct explanation using an example of copy constructor)

(c) Write the definition of a class ACCESSORY in C++ with the following description: 4

Private Members
● ANO // integer
● TYPE // char array of size 20
● SECTION // char
● SECASSIGN() /* Member function to assign value of
SECTION based upon TYPE as follows : */
TYPE SECTION
MOBILE A
COMPUTER B
CAMERA C
FASHION D

Public Members
GetOne() /* Function to allow user to enter values of ANO
and TYPE then invoke SECASSIGN() to assign SECTION */

ShowOne() /* Function to display values of ANO, TYPE and


SECTION */

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #7/43]


Ans class ACCESSORY
{ int ANO;
char TYPE[20],SECTION;
void SECASSIGN()
{
if (strcmp(TYPE,"MOBILE")==0)
SECTION='A';
else if (strcmp(TYPE,"COMPUTER")==0)
SECTION='B';
else if (strcmp(TYPE,"CAMERA")==0)
SECTION='C';
else if (strcmp(TYPE,"FASHION")==0)
SECTION='D';
}
public:
void GetOne()
{ cin>>Ano;
gets(TYPE);
SECASSIGN();
}
void ShowOne()
{
cout<<Ano<<TYPE<<SECTION<<endl;
}
};
( 1 mark for correctly defining class with data members)
( 1 mark for correctly defining member function SECASSIGN())
( 1 mark for correctly defining member function GetOne())
( 1 mark for correctly defining member function ShowOne())

(d) Answer the questions (i) to (iv) based on the following : 4


class GM
{
int MID;
protected:
double Sal;
void Calc();
public:
void Enter();
void Display();
};
class DIRECTOR
{
int DID;
protected:
double Fees;
public:
void Enter();
void Display();
};

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #8/43]


class STORE: private DIRECTOR, public GM
{
int STID;
public:
void Enter(); void Display();
};

void main()
{
STORE ST;
______________; //Statement
}

(i) Which type of Inheritance out of the following is illustrated in the above
example ?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

Ans Multiple Inheritance

( 1 mark for correct type name of the inheritance)

(ii) Write the names of all the data members, which are directly accessible by the
member function Display() of class STORE.

Ans Data members:


STID, Fees, Sal

( 1 mark for correctly mentioning all the data members)

Note: No partial marks for writing partial answer in this question

(iii) Write the names of all the member functions, which are directly accessible by
the object ST of class STORE in main().

Ans Member Functions:


Enter(), Display()
( 1 mark for correctly mentioning the names of member functions)

Note: No partial marks for writing partial answer in this question

(iv) Write the statement to call and execute Display() function of class GM by the
object ST declared in the main() function.
Ans ST.GM::Display()

( 1 mark for correct function call with scope resolution operator)

OR

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #9/43]


(d) Consider the following class Company : 4
class COMPANY
{
int CCODE;
char DES[20];
protected:
char LOCATION[40];
public:
void Register(){cin>>CCODE;gets(DES);gets(LOCATION);}
void Show(){cout<<CCODE<<DES<<CITY<<endl;}
};

Write a code in C++ to privately derive another class TRADER from the base
class COMPANY with the following members.

Data Members (private)


● STATE of type string
● TARGET of type float
Member Functions (public)
● A constructor function to assigns 1000.
● TraderReg() to allow user to enter STATE and TARGET, also call Register()
of COMPANY.
● ShowTrade() to display STATE and TARGET.
Ans class TRADER::private COMPANY
{
char STATE[20];
float TARGET;
public:
TRADER()
{ strcpy(STATE,”SOMESTATE”);
TARGET=1000;
}
void TraderReg()
{ gets(STATE);
cin>>TARGET;
Register();
}
void ShowTrade()
{ cout<<STATE<<TARGET<<endl;}
};
( 1 mark for correct syntax to inherit privalely)
( ½ mark for correctly including data members in class definition)
( ½ mark correctly defining constructor function)
( 1 mark for correctly defining TraderReg())
( 1 mark for correctly defining ShowTrade())

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #10/43]


3 (a) Write the definition of a function SWAPPER(int M[], int N)in C++, which should 3
SWAP alternate elements of the array M[] containing N number of integers,
where N is an even integer. The function should also display the swapped
content of the array.
Example : If the array M contains
0 1 2 3 4 5 6 7

18 13 12 17 16 21 14 15

Then the function should display the output as follows :


13
18
17
12
21
16
15
14
Ans void SWAPPER (int M[], int N)
{ int T;
for(i=0;i<N;i+=2)
{ T=M[i];
M[i]=M[i+1];
M[i+1]=T;
}
for(i=0;i<N;i++)
cout<<M[i]<<endl;
}
OR
Any valid code which serves the purpose
(1 mark for the correct uses of the first loop)
(1 mark for swapping the adjacent elements of the array M)
(1 mark for displaying the swapped array)
OR
Write the definition of a function FourQtr(int A[], int N) in C++, which should 3
display the sum of four quarters of the array A[] containing N number of
integers, where N is an even integer.
Example : If the array A contains the following elements for N=8
0 1 2 3 4 5 6 7

70 30 20 10 60 50 5 7
Then the function should display
100
30
110
12

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #11/43]


Ans void FourQtr(int A[], int N)
{
int Jump=N/4,Q[4]={0,0,0,0};
for (int I=0;I<N;I+=Jump)
for (int J=I;J<I+Jump;J++)
Q[I/Jump]+=A[J];
for (I=0;I<4;I++)
cout<<Q[I]<<endl;
}

OR
void FourQtr(int A[], int N)
{
int Q1=0,Q2=0,Q3=0,Q4=0;
int U1=N/4,U2=N/2,U3=3*N/4;
for(i=0;i<U1;i++)
Q1+=A[i];
for(i=U1;i<U2;i++)
Q2+=A[i];
for(i=U2;i<U3;i++)
Q3+=A[i];
for(i=U3;i<N;i++)
Q4+=A[i];
cout<<Q1<<endl<<Q2<<endl<<Q3<<endl<<Q4<<endl;
}

OR
Any valid code which serves the purpose
(1 mark for initialising four quarter correctly)
(1 mark for calculating four quarter correctly)
(1 mark for displaying four quarter correctly)

(b) Write the definition for a function TOPDIAG(int T[4][4]) in C++, which displays 2
the portion content of the 2D array as displayed in the example below. For
example :

ARRAY T CONTENT TO BE DISPLAYED

12 14 16 18 12 14 16 18

10 11 13 15 10 11 13

22 24 26 28 22 24

20 21 23 25 20

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #12/43]


Ans void TOPDIAG(int T[4][4])
{
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
if ((i+j)<4)
cout<<T[i][j]<<'\t';
cout<<endl;
}

OR
Any valid code which serves the purpose
(1 mark for uses of the correct loops)
(½ mark for identifying the correct elements)
OR

(b) Write the definition for a function DiagSum(int P[4][4]) in C++, which finds and 2
displays the sum of values on both the diagonal elements separately.
For example :

ARRAY P OUTPUT

20 15 25 50 Sum of Diagonal 1 : 190

35 30 40 15 Sum of Diagonal 2 : 210

55 50 60 45

70 75 85 80

Ans void DiagSum(int P[4][4])


{
int D1=0,D2=0;
for(int I=0;I<4;I++)
{
D1+=A[I][I];
D2+=A[3-I][I];
}
cout<<"Sum of Diagonal 1:"<<D1<<endl;
cout<<"Sum of Diagonal 2:"<<D2<<endl;
}

OR
Any valid code which serves the purpose
(1 mark for uses of the correct loops)
(½ mark for identifying the correct elements)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #13/43]


(c) Let us assume S[15][25] is a two-dimensional array, which is stored in the 3
memory along the column with each of its element occupying 4 bytes, find the
address of the element S[5][15], if the address of the element S[2][5] is 15000.
Ans LOC(S[I][J]) = Base(S) + W * (NR * J + I)
LOC(S[2][5]) = Base(S) + W * (NR * J + I)

15000 = Base(S) + 4 * (15 * 5 + 2)


Base(S) = 15000 - 4 * 77
Base(S) = 15000 - 308
Base(S) = 14692

LOC(S[5][15])= 14692 + 4 * (15 * 15 + 5)


= 14692 + 4 * (225 + 5)
= 14692 + 4 * 230`
= 14692 + 920
= 15612
(1 Mark for using the correct formula/substitution of values in formula for
column major)
(1 Mark for using the given reference address to find Base(S))
(1 Mark for final correct result)
OR

(c) If K[2...10][-2...20] is a two-dimensional array, which is stored in the memory 3


along the row with a base address as 52000 and each of its element occupying 2
bytes, find the address of the element K[5][10].
Ans LOC(K[I][J]) = Base(K) + W * (NC * (I - LBR) + (J - LBJ))
= 52000 + 2 * (23 * (5 - 2) + (10 + 2))
= 52000 + 2 * (23 * 3 + 12)
= 52000 + 2 * (69 + 12)
= 52000 + 2 * 81
= 52000 + 162
= 52162
(1 Mark for using the correct formula/substitution of values in formula for
column major)
(1 Mark for at least one line of intermediate calculation)
(1 Mark for final correct result)
(d) Write the definition of a function 4
QInsert(float Q[], int &R, int F),

which inserts a value in a circular static queue Q[ ] (here, consider parameters


R as rear end of the queue and F as front end of the Queue). Also, check for a
condition if the queue is full or not before performing insertion, the function
should display a message “Queue is FULL” when the Queue is full.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #14/43]


Ans void QInsert(float Q[], int &R, int F)
{
// Assuming global variable MAX is the size of Q[]
if ((R+1)%MAX == F)
cout<<"Queue is FULL\n";
else
{
R=(R+1)%MAX;
cout<<"Enter the new element: ";
cin>>Q[R];
}
}

OR

void QInsert(float Q[], int &R, int F)


{
// Assuming global variable MAX is the size of Q[]
if ((F==0 && R==MAX-1) || (F==R+1))
cout<<"Queue is FULL\n";
else
{
R=R+1;
if (R==MAX)
R=0;
cout<<"Enter the new element: ";
cin>>Q[R];
}
}
(1 mark for checking overflow)
(1 mark for displaying desired message in case of overflow)
(1 mark for updated the value of R)
(1 mark for assigning new element into the queue)
OR

(d) For the following structure of ITEM in C++ 4


struct ITEM
{
int ID;
char Qty;
ITEM *Next;
};

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #15/43]


Given that the following declaration of class ITEMQUEUE in C++, which is
representing a dynamic queue of ITEM (as per the structure ITEM declared
above) :
class ITEMQUEUE
{
ITEM *R, *F; //Pointers with addresses of Rear and Front
public:
ITEMQUEUE()
{
R=NULL; F=NULL;
}
//A Function to insert an Item in the dynamic queue
void QINSERT();
//A Function to delete an Item from the dynamic queue
void QDELETE();
~ITEMQUEUE();
};

Write the definition for the member function void ITEMQUEUE::QINSERT(), that
will insert an item into the dynamic queue of ITEMQUEUE (take necessary input
from user).
Ans void ITEMQUEUE::QINSERT()
{
ITEM *Temp = new ITEM;
cout<<"Enter ID : ";
cin>>Temp->ID;
cout<<"Enter Qty: ";
cin>>Temp->Qty;
Temp->Next=NULL;
if (F==NULL)
F=R=Temp;
else
{
R->Next=Temp;
R=Temp;
}
}

(1 mark for reading data from the user)


(½ mork for storing data from the user to a temporary pointer)
(½ mark for assigning NULL to the Next value of the temporary pointer)
(1 mark for checking empty queue)
(1 mark for updating the values of F and R)
(e) Evaluate the following Postfix expression, showing the stack contents : 2

350,5,/,19,2,*,20,-,-

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #16/43]


Ans
POSTFIX OPERATION STACK
350 PUSH 350
5 PUSH 350 5
/ POP POP OPERATE PUSH 70
19 PUSH 70 19
2 PUSH 70 19 2
* POP POP OPERATE PUSH 70 38
20 PUSH 70 38 20
- POP POP OPERATE PUSH 70 18
- POP POP OPERATE PUSH 52

(½ mark for evaluating up to the first operator '/')


(½ mark for evaluating up to the second operator '*')
(½ mark for evaluating up to the third operator '-')
(½ mark for evaluating up to the last operator '-')
OR

(e) Convert the following Infix expression to its equivalent Postfix expression, 2
showing the stack contents for each step of conversion :

U - V / W * R + T
Ans
Scanned Stack Postfix
Element

( (

U ( U

- (- U

V (- UV

/ (-/ UV

W ( - / UVW

* ( - * UVW /

R ( - * UVW / R

+ ( + UVW / R * -

T ( + UVW / R * - T

) Empty UVW / R * - T +

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #17/43]


(½ mark for finding postfix up to the operator '-')
(½ mark for finding postfix up to the operator '/')
(½ mark for finding postfix up to the operator '*')
(½ mark for finding postfix up to the operator '+')

4. (a) A text file named PRAYER.TXT contains some text. Write a function definition 3
GODLINES() in C++ that would read each line of PRAYER.TXT and display those
lines, which are starting with GOD.
Ans void GODLINES()
{
ifstream F("PRAYER.TXT");
char Line[80];
while (F.getline(Line,80))
if (Line[0]=='G' && Line[1]=='O' && Line[2]=='D')
cout<<Line<<endl;
F.close();
}
(1 Mark for opening PRAYER.TXT correctly)
(1 Mark for reading each Line (using any method) from the file)
(½ Mark for checking the Line starting with GOD)
(½ Mark for displaying the Line)

OR

(a) A text file named NOTES.TXT contains some text. Write the function definition 3
DISPLAY2() in C++ which displays first 2 letters of each word of the text file.

For example : If the file NOTES.TXT contains :


PYTHON IS ONE LANGUAGE AND C++ IS ANOTHER LANGUAGE

Then the function should display the output as :


PY IS ON LA AN C+ IS AN LA
Ans void DISPLAY2()
{
ifstream f("NOTES.TXT");
char W[20];
while(f>>W)
{
if(strlen(W)>1)
cout<<W[0]<<W[1]<<” “;
}
f.close();
}
(1 Mark for opening NOTES.TXT correctly)
(1 Mark for reading each Word (using any method) from the file)
(1 Mark for displaying first two characters of the word correctly)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #18/43]


(b) Write a definition for function NORTHTRADE() in C++ to read each object of a 2
binary file TRADER.DAT, find and display the Total amount of trade done by
traders from NORTH region.

Assume that the file TRADER.DAT is created with the help of objects of class
Trader, which is defined below :

class Trader
{
int Code;char Region[20]; float Amount;
public:
void RegTrader();
void ShowTrader();
float GetAmount() { return Amount; }
char* GetRegion() { return Region; }
};

Ans void NORTHTRADE()


{
ifstream F;
F.open("TRADER.DAT",ios::binary|ios::in);
Trader T;
int sum=0;
while(F.read((char*)&T,sizeof(T)))
if (strcmp(T.GetRegion(),"NORTH")==0)
sum+=T.GetAmount();
cout<<"Total Amount= "<<sum;
F.close()
}

(½ Mark for opening TRADER.DAT correctly)


(½ Mark for reading each record from the file)
(½ Mark for calculating the Total Amount correctly)
(½ Mark for displaying the Total Amount)

OR

A binary file SWEETS.DAT contains records stored as objects of the following 2


class :
class Sweet
{
int SCode; char Sweet[20]; int Qty;
public:
int GetSCode(){ return Scode; }
int GetQty(){ return Qty; }
void Show()
{ cout<<SCode<<" : "<<Sweet<<" : <<Qty<<endl;
};

Write definition for function ShowHigh() in C++, which displays the details of
those sweets from the file SWEETS.DAT, whose Qty is more than 1000.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #19/43]


Ans void ShowHigh()
{
ifstream F;
F.open("SWEETS.DAT",ios::binary|ios::in);
Sweet S;
while(F.read((char*)&S,sizeof(s)))
if (S.GetQty()>1000)
S.Show()
F.close()
}
(½ Mark for opening SWEETS.DAT correctly)
(½ Mark for reading each record from the file)
(½ Mark for checking quantity more than 1000 from the file)
(½ Mark for displaying the record)
(c) Find the output of the following C++ code considering that the binary file 1
CHANNEL.DAT exists on the hard disk with the following 6 records for the class
CHANNEL containing CNAME and TO (TURNOVER in Crore).

CNAME TURNOVER class CHANNEL


KIDIES 11 {
char CNAME[20]; int TO;
NEWSFAST 60
public;
QUICKNEWS 20 void GetC();
CARTOONX 45 void ShowC()
{ cout<<CNAME<<”:”
GAMEZ 50 <<TO<<endl;}
MOVIETRACKER 62 };

void main()
{
fstream F;
F.open("CHANNEL.DAT",ios::binary|ios::in);
CHANNEL C;
F.seekg(3*sizeof(C));
F.read((char*)&C, sizeof(C));
F.read((char*)&C, sizeof(C));
C.ShowC();
F.close();
}
Ans GAMEZ:50

(1 Mark for displaying correct values of Record 5 )

OR
(c) Differentiate between seekp() and tellp(). Give a suitable example to illustrate 1
the difference.
Ans tellp(): This function returns the position of the current
put pointer in terms of bytes in a file.
int n = f.tellp();
seekp(): This function takes the file put pointer to the
specified byte in a file.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #20/43]


Eg: f.seekp(30); // It takes a pointer to the 30th byte.
(½ Mark for differentiating between tellp() and seekp())
(½ Mark for giving suitable example)

SECTION B
[Only for candidates, who opted for Python]
1 (a) What is the difference between logical error and run-time error ? Give a 2
suitable example of each.
Ans Logical error: :Logical error occurs when there is a fault in the logic of Program
Logical errors are difficult to trace and can cause a program to produce
unexpected results.
Example
A=10
B=20
C=A*B
print C

Multiplying two numbers instead of adding them together may also produce
unwanted results.

Runtime error: A runtime error is an error that causes abnormal termination of


program during running time.

Example
A=10
B=int(raw_input("Value:"))
print A/B
# If B entered by user is 0, it will be run-time error
( ½ mark each for defining Logical error and run-time error )
( ½ mark for each correct example)
OR
( Full 2 Marks for illustrating both through examples)
(b) Name the Python Library modules which need to be imported to invoke the 1
following functions :
(i) factorial()
(ii) group()
Ans (i) math
(ii) grp

(1 Mark for writing correct Library module for factorial() )


(ii) to be ignored

(c) Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.
Val = 32
for K in range(20:32):
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #21/43]
if K>25
print K*Val
Else:
PRINT K+ValNumber
Ans Val = 32
for K in range(20,32): # Error 1
if K>25 : # Error 2
print K*Val
else: # Error 3
print K+Val # Error 4 and Error 5
(½ Mark for each correction, not exceeding 2 Marks)
OR
(1 mark for identifying the errors, without suggesting corrections)
(d) Find and write the output of the following Python code : 2

Txt="Some2Thing"
STxt=""
Fold=0
for C in range(0,len(Txt)):
if Txt[C]>="0" and Txt[C]<="9":
Fold=1
STxt = STxt + "#"
elif Fold==0 and Txt[C]>="A" and Txt[C]<="S":
STxt = STxt + "@"
elif Fold==1 and Txt[C]>="T" and Txt[C]<="Z":
STxt = STxt + "*"
else:
STxt = STxt + Txt[C]
print STxt
Ans @ome#*hing
( ½ Mark for mentioning @om)
( ½ Mark for e# correctly)
( ½ Mark for *hi)
( ½ Mark for ng)
(e) Find and write the output of the following Python code : 3

def Compute(A,B,C="*"):
for I in range(A,B+1):
if I%2==0:
print I,C,
else:
print I,"@",
print " "
Compute(10,14)
Compute(25,29,"#")
Compute(5,10)
Ans Indentation Error

OR

10 *
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #22/43]
11 @

12 *

13 @

14 *

25 @

26 #

27 @

28 #

29 @

5 @

6 *

7 @

8 *

9 @

10 *

OR

10 *
12 *
14 *
14 @

26 #
28 #
29 @

6 *
8 *
10 *
10 @
(3 Marks for mentioning Indentation Error in question)
OR
(Full 3 mark for writing six correct values out of the above outputs)
(f) Out of the (i) to (iv) options, which is/are not possible outputs(s) of the 2
following program code ? Also specify the maximum value that can be assigned
to the variable R.

import random

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #23/43]


ALPHA=["A","C","E","F","G","B"]
fOR I in range(1,4):
R=random.randint(I,5)
print ALPHA[R],":",

(i) F : B : F : (ii) C : G : F :

(iii) A : G : F : (iv) G : B : G :

Ans Syntax Error


OR
(iii) A:G:F:
Maximum value or R: 5

(2 Marks for mentioning Syntax Error in question)


OR
(1 mark for correct option)
(1 mark for Maximum value of R)

2 (a) Explain the concept of Polymorphism in Python. Write suitable example to 2


illustrate the concept of Polymorphrism.
Ans Polymorphism is the ability to use an operator or function in various forms.
That is a single function or an operator behaves differently depending upon
the data provided to them.
Example
def test(): #function 1
print "hello"
def test(a, b): #function 2
return a+b
def test(a, b, c): #function 3
return a+b+c

(1 Mark for correct explanation of Polymorphism)


(1 Mark for writing any suitable example)
OR
(2 Marks if the concept is explained through an example)
(b) class SHOP: #Line 1 2
NUM = 100 #Line 2
CATEG="GEN.STORE" #Line 3
def __init__(self,C,N=25): #Line 4
self.NUM = N #Line 5
self.CATEG = C #Line 6
def SHOW(self): #Line 7
print self.NUM,self.CATEG #Line 8
print SHOP.CATEG,SHOP.NUM #Line 9
S1=SHOP("TOYS") #Line 10
S1.SHOW() #Line 11

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #24/43]


S2=SHOP("FURNITURE",105) #Line 12
SHOP.CATEG="GAMES" #Line 13
S2.SHOW() #Line 14
Write the output of the above Python code.

Ans 25 TOYS
GEN.STORE 100
105 FURNITURE
GAMES 100
( ½ Mark for each correct line of output)

OR
(b) class Flat: #Line 1
def __init__(self): #Line 2
self.No = 100 #Line 3
self.Floor = 2 #Line 4
def __del__(self): #Line 5
print "Sold Out" #Line 6
def VIEW(self): #Line 7
print self.No,self.Floor #Line 8
def Buy(): #Line 9
F=Flat() #Line 10
F.VIEW() #Line 11
Buy() #Line 12

(i) Which statement (Line number) out of Line 1 to Line 8 will be called and get
executed first, when statement at Line 10 gets executed ? Justify your answer.
Ans Lines 2,3, 4 will get executed
The given statement in Line 10 creates an Object of the Class Flat, which will
invoke the constructor defined in lines 2,3,4
(½ Mark for writing the statements that will get executed)
(½ Mark for writing the justification)
(ii) What will be the output of the above code ?
Ans 100 2
Sold Out
( ½ Mark for each correct line of output)
(c) Define a class CLUB in Python with following specifications : 4
Instance Attributes
- ID # Member Number
- Mname # Member Name
- Activity # Activity
- Fee # Membership Fee

Methods/function

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #25/43]


- GetFee() # To assign Fee
# as per Activity chosen by member as follows :
Activity Fee
Badminton 1500
Table Tennis 1200
Football 600
Gym 2500

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


# ID, Mname and Activity.
# The function should also
# call GetFee() to assign Fee
- View() # To display ID, Mname, Activity and Fee
Ans class CLUB:
def __init__(self):
self.ID = 0
self.Mname = ""
self.Activity= ""
self.Fee=0
def GetFee(self):
if self.Activity=="Badminton":
self.Fee=1500
elif self.Activity=="Table Tennis":
self.Fee=1200
elif self.Activity=="Football":
self.Fee=600
elif self.Activity=="Gym":
self.Fee=2500
def Register(self):
self.ID=int(input("ID:")
self.Mname=input("Name:")
self.Activity=input("Activity:")
GetFee(self)
def View(self):
print self.ID,self.Mname,self.Activity,self.Fee

( 1 Mark for correct definition of class)


( 1 Mark for defining GetFee())
( 1 Mark for defining Register())
( 1 Mark for defining View())
(d) Answer the questions (i) to (iii) based on the following :
class Manager(object): #Line 1
def __init__(self,SAL): #Line 2
self.MSAL = SAL
def LevelNext(self,S): #Line 3

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #26/43]


self.MSAL =self.MSAL+S
def MView(self): #Line 4
print self.MSAL
class Consultant(object): #Line 5
def __init__(self,FEE): #Line 6
self.CTEE=FEE
def Hike(self,F): #Line 7
self.FEE =self.FEE + F
def CView(self): #Line 8
print self.FEE
class Company(Manager,Consultant): #Line 9
def __init__(self,BGT): #Line 10
self.CBGT=BGT
Manager.__init__(self,BGT/5) #Line 11
Consultant.__init__(self,BGT/10) #Line 12
def Uplift(self,A): #Line 13
self.BGT=self.BGT+A
Manager.LevelNext(self,A/4)
Consultant.Hike(self,A/2)
def CMView(self): #Line 14
print self.BGT,
Manager.MView(self)
Consultant.CView(self)
CM=Company(12000000) #Line 15
CM.UpLift(20000)
CM.CMView()

(i) Write the type of the inheritance illustrated in the above. 1


Ans Multiple Inheritance
(1 Mark for writing correct type name of the Inheritance)
(ii) Which statements (line numbers) in the above program code will call and 2
execute statements written at Line 2 and Line 6 ?
Ans Line 11
Line 12
(1 Mark for writing Line 11)
(1 Mark for writing Line 12)
(iii) Find and write the output of the above code. 1
Ans 12020000
2405000.0
1210000.0
( 1 Mark for mentioning error in Variable Name)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #27/43]


OR
( 1 Mark for writing the output assuming corrected Variable Name)
OR
Write a Python code to illustrate example of inheritance depicting the following 4
information.

Ans class COMPANY(object):


def __init__(self,NAME,CITY):
self.NAME = NAME
self.CITY = CITY
def Get(self):
self.NAME = "AMAN"
self.CITY = "AGRA"
def View(self):
print self.NAME, self.CITY
class BRANCH(COMPANY):
def __init__(self,NAME,CITY):
self.NAME = NAME
self.CITY = CITY
def Get(self):
self.NAME = "RAJ"
self.CITY = "CHENNAI"
def View(self):
print self.NAME, self.CITY
class STORE(BRANCH):
def __init__(self,NAME,CITY):
self.NAME = NAME
self.CITY = CITY

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #28/43]


def Get(self):
self.NAME = "TARUN"
self.CITY = "JAIPUR"
def View(self):
print self.NAME, self.CITY

(1 Mark for writing definition of each of the class)


(1 Mark for correctly using the syntax of the inheritance)
3 (a) Consider the following randomly ordered numbers stored in a list : 3
16, 14, 18, 12, 15, 11

Show the content of list after the First, Second and Third pass of the bubble sort
method used for arranging in descending order ?

Note : Show the status of all the elements after each pass very clearly encircling
the changes.
Ans
PASS 0 1 2 3 4 5

16 14 18 12 15 11

First 14 16 12 15 11 18

Second 14 12 15 11 16 18

Third 12 14 11 15 16 18

12 11 14 15 16 18

11 12 14 15 16 18

( 1 Mark for correctly showing status of the content after each pass upto
Third Pass)
OR
Consider the following randomly ordered numbers stored in a list : 3
16, 14, 16, 12, 15, 17

Show the content of the list after the First, Second and Third pass of the
selection sort method used for arranging in ascending order.

Note : Show the status of all the elements after each pass very clearly
encircling the changes.
Ans
PASS 0 1 2 3 4 5

16 14 16 12 15 17

First 11 16 12 15 14 18

Second 11 12 16 15 14 18

Third 11 12 14 15 16 18

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #29/43]


11 12 14 15 16 18

11 12 14 15 16 18

( 1 Mark for correctly showing status of the content after each pass upto
Third Pass)
(b) Write definition of a method/function TenSum(SCORES) to find and display sum 3
of those scores which are less than 500 and ending with 0.

For example,
If the SCORES contain [150,206,370,110,920,530,501,120]

The function should display


Ten Sum: 640
Ans def TenSum(SCORES):
SUM=0
for S in SCORES:
if S>=500 and S%10==0:
SUM+=S
print SUM

( ½ Mark for correct syntax for function definition)


( ½ Mark for initialization of a variable to 0 for SUM)
( ½ Mark for correctly used loop)
( ½ Mark for two conditions)
( ½ Mark for adding the value to variable used for SUM)
( ½ Mark for displaying the SUM)
OR
Write definition of a method/function NotLess(PRICE, LowPrice) to count and 3
display number of values of PRICE, which are not less than LowPrice.
For Example :
If the PRICE contains [100,120,103,180,162,113] and LowPrice contains 115 The
function should display

3 Prices are not less than 115


Ans def NotLess(PRICE, LowPrice):
NUM=0
for P in PRICE:
if P>LowPrice:
NUM+=1
print NUM,"Prices are not less than",LowPrice

( ½ Mark for correct syntax for function definition)


( ½ Mark for initialization of a variable to 0 for NUM)
( ½ Mark for correctly used loop)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #30/43]


( ½ Mark for condition)
( ½ Mark for the increment in NUM)
( ½ Mark for displaying the NUM)
(c) Write QueueIn(ITEM) and QueueDel(ITEM) methods/function in Python to add a 4
new ITEM and delete an ITEM from a list ITEM containing item names,
considering them to act as insert and delete operations of the Queue data
structure.
Ans def QueueIn(ITEM):
A=input("A:")
ITEM.insert(0,A)
def QueueDel(ITEM):
if ITEM == []:
print "Queue is EMPTY"
else:
print ITEM.pop()

( 1 Mark for syntax of definitions of QueueIn() and QueueDel())


( 1 Mark for correctly adding content in list as per Queue)
( 1 Mark for correctly checking the Empty condition in QueueDel())
( 1 Mark for correctly deleting the element from list as per Queue)
OR
(c) Write PushBox(BOX) and PopBox(BOX) methods/function in Python to add a new 4
BOX and delete a BOX from a List of BOX of fruits, considering them to act as
push and pop operations of the Stack data structure.
Ans def PushBox(BOX):
B=input("B:")
BOX.append(B)
def PopBox(BOX):
if BOX == []:
print "Stack is EMPTY"
else:
print BOX.pop()

( 1 Mark for syntax of definitions of PushBox() and PopBox())


( 1 Mark for correctly adding content in list as per Stack)
( 1 Mark for correctly checking the Empty condition in PopBox())
( 1 Mark for correctly deleting the element from list as per Stack)
(d) Write a Python method/function SWapPair(COLORS) to swap the alternate 2
values of the content of a list COLORS and display the final values of COLORS.

Note : Assuming that the list has even number of values in it. For Example :

If the list COLORS contains


["RED","BLACK","WHITE","PINK", "CYAN","BLUE"]
After swap pair operation the content should be displayed as
BLACK RED PINK WHITE BLUE CYAN
Ans def SWapPair(COLORS):

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #31/43]


for i in range(0,len(COLORS)-1,2):
COLORS[i],COLORS[i+1]=COLORS[i+1],COLORS[i]
for C in COLORS:
print C,end=" "

( ½ Mark for correct use of syntax of function definition)


( ½ Mark for correct use of loop)
( ½ Mark for correctly swapping the adjacent elements)
( ½ Mark for displaying the content after change in content)
OR
(d) Write a Python method/function DispFactors(N) to find and display all the 2
factors of an integer N (parameter).
For Example :
If the value of N is 28
The output should be displayed as
1 2 4 7 14 28
Ans def DispFactors(N):
for i in range(N+1):
if N%i==0:
print(i, end=" ")
( ½ Mark for correct use of syntax of function definition)
( ½ Mark for correct use of loop)
( ½ Mark for divisibility check)
( ½ Mark for displaying the factor)
(e) Evaluate the following Postfix expression, showing the stack contents : 2
65,5,/,40,+,9,5,*,-
Ans
POSTFIX OPERATIONS STACK
65 PUSH 65
5 PUSH 65 5
/ POP POP OPERATE PUSH 13
40 PUSH 13 40
+ POP POP OPERATE PUSH 53
9 PUSH 53 9
5 PUSH 53 9 5
* POP POP OPERATE PUSH 53 45
- POP POP OPERATE PUSH 8

(½ mark for evaluating up to the first operator '/')


(½ mark for evaluating up to the second operator '+')
(½ mark for evaluating up to the third operator '*')
(½ mark for evaluating up to the last operator '-')
OR
(e) Convert the following Infix expression to its equivalent Postfix expression, 2
showing the stack contents for each step of conversion :
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #32/43]
U * V + W / (X - Y)
Ans ((U * V) + (W / (X - Y)))

INFIX STACK POSTFIX


((
U U
* * U
V * U V
) U V *
+ + U V *
( + U V *
W + U V * W
/ + / U V * W
( + / U V * W
X + / U V * W X
- + / - U V * W X
Y + / - U V * W X Y
) + / U V * W X Y -
) + U V * W X Y - /
) U V * W X Y - / +

(½ mark for finding postfix up to the operator '*')


(½ mark for finding postfix up to the operator '+')
(½ mark for finding postfix up to the operator '/')
(½ mark for finding postfix up to the operator '-')
4 (a) Write a statement in Python to open a text file MEETUP.TXT so that existing 1
content can be read from it.
Ans F.write(Line+"\n")
OR
F.write("Hello! Its a nice day\n")
( ½ Mark for using write function)
( ½ Mark for displaying a line of content using write function)
OR

(a) Write a statement in Python to open a text file NOTICES.TXT so that new 1
contents can be written in it.
Ans F=open("NOTICES.TXT","w")
OR
F=open("NOTICES.TXT","a")
OR
with open("NOTICES.TXT","w") as F:
OR
with open("NOTICES.TXT","a") as F:
( ½ Mark for using open function)
( ½ Mark for correctly specifying file mode)
(b) Write a method/function FIRSTTWO() in Python to read contents from a text 2

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #33/43]


file PRAY.TXT, to find and display the first two characters of every word of the
file. For example :
If the content of the file is
____________________________________________________________________
WE LOVE OUR COUNTRY AND WE PRAY WELL BEING OF ALL
____________________________________________________________________
The method/function should display
WE LO OU CO AN WE PR WE BE OF AL
Ans def FIRSTTWO():
with open("PRAY.TXT") as F:
TL=F.readlines()
for L in TL:
for W in L.split():
print W[:2],end=" "
( ½ Mark for using open function in "r" mode)
( ½ Mark for reading the content from file)
( ½ Mark for correctly extracting words from the content of the file)
( ½ Mark for displaying the first two letters of each word)
OR

Write a method/function APCount() in Python to read and display the count of 2


those lines from a text file STATES.TXT, which are starting either with M or
starting with P.

For example :
If the content of the file is
MIZORAM IS IN THE NORTH EAST OF INDIA
PUNJAB IS PROSPEROUS LAND
KERALA IS MOST LITERATE STATE
MUMBAI IS FILM CITY
MANIPUR IS FAMOUS FOR LOKTAK LAKE

The method should display


4
Ans def APCOUNT():
with open("PRAY.TXT") as F:
CNT=0
TL=F.readlines()
for L in TL:
if L[0] in "mM":
CNT+=1
print CNT
( ½ Mark for using open function in "r" mode)
( ½ Mark for reading the content from file)
( ½ Mark for correctly using loop)
( ½ Mark for correctly checking first character M and counting)
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #34/43]
(c) Considering the following definition of class TRADING, write a method/function 3
SOUTHTRADE() in Python to find and display the total amount of trade
happened in SOUTH region from a pickled file TRADING.DAT containing records
of TRADING.

class TRADING:
def __init__(self,R,A):
self.Region=R
self.Amount=A
def Display(self):
print self.Region,"#", self.Amount

Ans import pickle


def SOUTHTRADE():
F=open("TRADING.DAT","rb")
while True:
try:
Recs=pickle.load(F)
if Recs.Region=="SOUTH":
Recs.Display()
except:
break
F.close()
( ½ Mark for correct import statement)
( ½ Mark for opening the file)
( ½ Mark for reading the content from file)
( 1 Mark for correctly matching Region with “SOUTH” )
( ½ Mark for correctly displaying matched record)
OR

Considering the following definition of class GAMER, write a method/function 3


GAMING() in Python to search and display all the content from a pickled file
GAMER.DAT where Type of GAMER is "MOBILE".

class GAMER:
def __init__(self,I,T):
self.ID=I
self.TYPE=T # PC,CONSOLE, MOBILE, INTERNET
def Show(self):
print self.ID,"#", self.TYPE

Ans import pickle


def GAMING():
F=open("GAMER.DAT","rb")
while True:
try:
Recs=pickle.load(F)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #35/43]


if Recs.TYPE=="MOBILE":
Recs.Show()
except:
break
F.close()

( ½ Mark for correct import statement)


( ½ Mark for opening the file)
( ½ Mark for reading the content from file)
( 1 Mark for correctly matching TYPE with “MOBILE” )
( ½ Mark for correctly displaying matched record)
SECTION C
[For all candidates]

5 (a) Observe the following table FOOD carefully and answer the questions that 2
follow :
TABLE: FOOD
AVGPRICE FNAME FNO ORIGIN
75 DOSA F01 SOUTH INDIA
100 BURGER F03 AMERICAN
45 VADA PAV F04 MAHARASHTRA
70 CHOW MEIN F09 CHINA
70 CHOLE BHATURE F15 PUNJAB
80 SARSON KA SAAG F12 RAJASTHAN
25 MAKKI KI ROTI F11 RAJASTHAN

(i) What is the Degree and Cardinality of table FOOD ?

Ans Degree: 4
Cardinality: 7
(½ Mark for writing correct Degree)
(½ Mark for writing correct Cardinality)
(ii) Which attribute out of AVGPRICE, FNAME, FNO and ORIGIN of table FOOD is
the ideal one for being considered as the Primary Key and why ?
Ans Primary Key: FNO OR FNAME (any one)
Reason: Unique values for identification of each tuple/record
(½ Mark for writing correct Primary key)
(½ Mark for writing correct Reason)
(b) Write SQL queries for (i) to (iv) and write outputs for SQL queries (v) to (viii), 6
which are based on the following tables :

TABLE: FURNITURE
FNO FNAME MATERIAL QTY SUPID
F01 CLASSIC BED WOOD 12 S01
F02 SOFT SOFA LEATHER 50 S05
F03 SHAHI BED METAL 5 S06

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #36/43]


F09 TERRACE CHAIR PLASTIC 120 S04
F12 CLASSIC CHAIR WOOD 300 S02
F11 DINING TABLE WOOD 45 S01
F23 SIDE TABLE GLASS 200 S02
F15 DINING CHAIR WOOD 300 S01
F19 RELAXER LEATHER 50 S05
F04 BUSINESS CHAIR METAL 450 S06

TABLE: SUPPLIER
SUPID SNAME TURNOVER CONTACT
S01 WOOD FINISHERS 5600000 P K MANTRA
S02 SHINE N CUT 12000000 F SAHOO
S04 PLASTINA TECH 32000000 T CHANDRA
S05 SOFTELIA 56000000 S JOHN
S06 SOLID METALS 45000000 P C KATKAR

(i) To display details of all the furniture from table FURNITURE, which are either
GLASS or LEATHER material.
Ans SELECT * FROM FURNITURE
WHERE MATERIAL = 'GLASS' OR MATERIAL = ‘LEATHER’;
Or
SELECT * FROM FURNITURE
WHERE MATERIAL IN ('GLASS', 'LEATHER');

(½ Mark for correct SELECT statement)


(½ Mark for correct WHERE clause)

(ii) To display the FNO, FNAME, QTY of those furnitures from table FURNITURE,
whose QTY is more than 100.
Ans SELECT FNO, FNAME, QTY FROM FURNITURE WHERE QTY>100;

(½ Mark for correct SELECT statement)


(½ Mark for correct WHERE clause)
(iii) To count number of suppliers from table SUPPLIER, whose TURNOVER is more
than 25000000.
Ans SELECT COUNT(*) FROM SUPPLIER WHERE TURNOVER > 25000000;

(½ Mark for correct SELECT statement)


(½ Mark for correct WHERE clause)
(iv) To display details of all furniture from table FURNITURE in descending order of
FNO.
Ans SELECT * FROM FURNITURE ORDER BY FNO DESC;

(½ Mark for correct SELECT statement)


(½ Mark for correct ORDER BY clause)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #37/43]


(v) SELECT MAX(TURNOVER), MIN(TURNOVER) FROM SUPPLIER;

Ans MAX(TURNOVER) MIN(TURNOVER)


56000000 5600000
(½ Mark for writing correct output, ignore the output heading)

(vi) SELECT SUM(QTY), MATERIAL FROM FURNITURE


GROUP BY MATERIAL HAVING COUNT(*)>2;
Ans SUM(QTY) MATERIAL
657 WOOD
(½ Mark for writing correct output, ignore the output heading)

(vii) SELECT DISTINCT MATERIAL FROM FURNITURE;

Ans DISTINCT(MATERIAL)
WOOD
LEATHER
METAL
PLASTIC
GLASS
(½ Mark for writing correct output, ignore the output heading)

(viii) SELECT FNAME, SNAME FROM FURNITURE F, SUPPLIER S


WHERE F.SUPID = S.SUPID AND QTY=300;
Ans FNAME SNAME
CLASSIC CHAIR SHINE N CUT
DINING CHAIR WOOD FINISHERS
(½ Mark for writing correct output, ignore the output heading)

6 (a) State any one De Morgan’s Law of Boollean Algebra and verify it using truth 2
table.
Ans (X+Y)’=X’.Y’
Verification:
X Y X+Y (X+Y)’ X’ Y’ X’.Y’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0

OR

(X.Y)’=X’+Y’
Verification:
X Y X.Y (X.Y)’ X’ Y’ X’+Y’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #38/43]
(2 Mark for correctly verifying the (X+Y)’ =X’.Y’ using Truth Table)
OR
(2 Mark for correctly verifying the (X.Y)’ =X’+Y’ using Truth Table)
(b) Draw the Logic Circuit of the following Boolean Expression : 2
A’.(B’ + C) + D’
Ans

( ½ Mark for interpretation of each of the NOT gates as per the


expression)
( ½ Mark for the first level OR gate as per the expression)
( ½ Mark for the AND gate as per the expression)
( ½ Mark for the second level OR gate as per the expression)
(c) Derive a Canonical POS expression for a Boolean function F, represented by the 1
following truth table :

P Q R F (P,Q,R)
0 0 0 1
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 0

Ans F(P,Q,R)= (P+Q’+R).(P’+Q+R).(P’+Q+R’).(P’+Q’+R’)


OR
F(P,Q,R)= ∏(2,4,5,7)
(1 Mark for correctly writing the POS form)
OR
(½ Mark for any two correct terms)
Note: Deduct ½ mark if wrong variable names are written in the
expression
(d) Reduce the following Boolean Expression to its simplest form using K-Map : 3

F(U,V,W,Z) = ∑(0,2,4,5,8,10,11,13,14,15)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #39/43]


Ans

F(U,V,W,Z)=UW+V’Z’+U’VW’+VW’Z

F(U,V,W,Z)=UW+V’Z’+U’W’Z’+VW’Z

F(U,V,W,Z)=UW+V’Z’+U’VW’+UVZ
( ½ Mark for correctly representing K-Maps for the given expression)
( ½ Mark for each grouping)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #40/43]


( ½ Mark for final minimised form)
7 (a) Ms. Taruna Gehlot copied PEN DRIVE on to her Laptop and when she opened the 2
file, her Laptop functions slowed down and other applications on the Laptop
stopped working properly. Specifically, which of the following could have
infected her Laptop files and Operating System out of the following ? Also,
mention, what she should do to remove this infection from her Laptop ? 2
(i) Spam Email
(ii) Worm
(iii) Virus
(iv) Trojan House
Ans (iii) Virus
OR
(iv) Trojan Horse

Use an antivirus application to prompt her about threats and to disinfect the
affected Laptop files and Operating System.
(1 Mark for writing any correct answer Virus OR Trojan Horse)
(1 Mark for writing any correct measure to remove the infection from her
Laptop)

(b) Mr. Priyaver Desai was travelling from Mumbai to Delhi for his vacation along 1
with his brand new Laptop (with no data and software installed in it) and one
brand new portable hard drive. These items, he had bought for gifting to his
nephew in Delhi. While travelling in the train, a co-traveller ran away with both
these items. Do you think Mr. Desai should report this as a Cyber Crime or any
other crime ? Write the reason for your answer.
Ans Mr. Desai should report to local police as regular theft.
Reason: Stealing of gadgets without any digital content is not considered a case
of Cyber crime.
(½ Mark for writing correct answer)
(½ Mark for writing correct reason)

(c) Give two differences between Video Conferencing and Text Chat service. 1
Ans
Video Conferencing Text Chat service
Video conferencing services allow real Text chat services allow you to receive
time communication between two or and reply to text messages.
more people.
SIP ( Session Initiation Protocol) is IRC (Internet Relay Protocol) is
required for Video Conferencing. required for Text chat services.

(½ mark each for any two valid differences)


(d) Write the expanded names for the following abbreviated terms used in 2
Networking and Communications :
(i) SMTP
(ii) GSM

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #41/43]


(iii) TCP
(iv) PPP
Ans (i) Simple Mail Transfer Protocol
(ii) Global System for Mobile Communication
(iii) Transmission Control Protocol
(iv) Point to point Protocol
(½ Mark for writing each correct expansion)
(e) Case Study Based Question
Global Knowledge Share Institute is planning to set up its centre in Hyderabad
with four specialised blocks for Computer Engineering, Mechanical Engineering,
Automobile Engineering along with Administration blocks in four 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 (i) to (iv) as raised by the financial advisers
of the institution.
Shortest distances between various locations in metres are as follows :

Computer Engg. to Mechanical Engg. Blocks 60


Computer Engg. to Automobile Engg. Blocks 40
Computer Engg. to Administration Blocks 60
Automobile Engg. to Mechanical Engg. Blocks 50
Automobile Engg. to Administration Blocks 110
Mechanical Engg. to Administration Blocks 40

Number of computers installed at various locations are as follows:


Administration Block 20
Computer Engg. Block 170
Mechanical Engg. Block 50
Automobile Engg. block 40

(i) Suggest the most suitable location to install the main server of Global 1
Knowledge Share Institute to get efficient connectivity with all the blocks.

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #42/43]


Ans COMPUTER ENGG. BLOCK
(1 Mark for writing correct location)
(ii) Suggest with the help of a drawing the best cable layout for effective network 1
connectivity between all the blocks.
Ans

(1 Mark for drawing any valid cable layout)


(iii) Out of the following, suggest the most suitable device to be installed in each of 1
these blocks for connecting all the computers installed within the centre :
● Modem, Switch, Gateway, Router
Ans Switch
(1 Mark for writing correct device)
(iv) Out of the following, suggest the most suitable wired medium for efficiently 1
connecting the blocks :
Network Cable: Optical Fiber, Ethernet Cable, Co-axial Cable, Single Pair
Telephone Cable.

Also, mention which Topology of network, will be formed by connecting all the
computer systems within each centre :
● Bus Topology or Star Topology
Ans Optical Fiber
Star Topology
(½ Mark for writing the correct network cable)
(½ Mark for writing the correct Topology)

Sub Code: 283 Series:3HKP35/C Paper Code: SET: 4 [Page #43/43]

You might also like