0% found this document useful (0 votes)
60 views

Computer ScienceSQP

This document provides a sample paper for Class XII Computer Science exam with questions in Sections A, B and C. Section A contains questions in C++ programming language. Question 1 has subparts a-f covering topics like functions, library functions, syntax errors, output of programs, classes and objects. Section B will contain questions in Python (not included here). Section C is compulsory for all students. The paper tests students on their knowledge of programming concepts and ability to write code in C++ and Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Computer ScienceSQP

This document provides a sample paper for Class XII Computer Science exam with questions in Sections A, B and C. Section A contains questions in C++ programming language. Question 1 has subparts a-f covering topics like functions, library functions, syntax errors, output of programs, classes and objects. Section B will contain questions in Python (not included here). Section C is compulsory for all students. The paper tests students on their knowledge of programming concepts and ability to write code in C++ and Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 141

CLASS-XII

COMPUTER SCIENCE
(Subject Code 083)
SAMPLE PAPER 2014 - 15

Time allowed : 3 hours Maximum Marks: 70

Instructions: (i) All questions are compulsory.


(ii) Programming Language: Section A C+ +.
(iii) Programming Language : Section B Python.
(iv) Answer either Section A or B, and Section C is
compulsory.

Section A (C++)

Q1. a. Differentiate between ordinary function and member functions in C++.


Explain with an example. [2]

b. Write the related library function name based upon the given information in
C++.

(i) Get single character using keyboard. This function is available in stdio.h file.
(ii) To check whether given character is alpha numeric character or not. This

function is available in ctype.h file. [1]

c. Rewrite the following C++ program after removing all the syntactical errors (if
any), underlining each correction. : [2]

include<iostream.h>
#define PI=3.14
void main( )
{ float r;a;
cout<<’enter any radius’;
cin>>r;
a=PI*pow(r,2);
cout<<”Area=”<<a
}

d. Write the output from the following C++ program code: [2]

#include<iostream.h>
#include<ctype.h>
void strcon(char s[])
{
for(int i=0,l=0;s[i]!='\0';i++,l++);
for(int j=0; j<l; j++)
{
if (isupper(s[j]))
s[j]=tolower(s[j])+2;
else if ( islower(s[j]))
s[j]=toupper(s[j])-2;
else
s[j]='@';
}
}
void main()
{
char *c="Romeo Joliet";
strcon(c);
cout<<"Text= "<<c<<endl;
c=c+3;
cout<<"New Text= "<<c<<endl;
c=c+5-2;
cout<<"last Text= "<<c
}

e. Find the output of the following C++ program: [3]

#include<iostream.h>
#include<conio.h>
#include<ctype.h>
class Class
{
int Cno,total;
char section;
public:
Class(int no=1)
{
Cno=no;
section='A';
total=30;
}
void addmission(int c=20)
{
section++;
total+=c;
}
void ClassShow()
{
cout<<Cno<<":"<<section<<":"<<total<<endl;
}
};
void main()
{
Class C1(5),C2;
C1.addmission(25);
C1.ClassShow();
C2.addmission();
C1.addmission(30);
C2.ClassShow();
C1.ClassShow();
}

f. Study the following C++ program and select the possible output(s) from it :
Find the maximum and minimum value of L. [2]

#include<stdlib.h>
#include<iostream.h>
#include<string.h>
void main()
{
randomize();
char P[]="C++PROGRAM";
long L;
for(int I=0;P[I]!='R';I++)
{
L=random (sizeof(L)) +5;
cout<<P[L]<<"-";
}
}
}

i) R-P-O-R-
ii) P-O-R-+-
iii) O-R-A-G-
iv) A-G-R-M-

Q2.a. How encapsulation and abstraction are implemented in C++ language?


Explain with an example. [2]

b. Answer the questions (i) and (ii) after going through the following C++ class:
[2]
class Stream
{
int StreamCode ; char Streamname[20];float fees;
public:
Stream( ) //Function 1
{
StreamCode=1; strcpy (Streamname,"DELHI");
fees=1000;
}
void display(float C) //Function 2
{
cout<<StreamCode<<":"<<Streamname<<":"<<fees<<endl;
}
~Stream( ) //Function 3
{
cout<<"End of Stream Object"<<endl;
}
Stream (int SC,char S[ ],float F) ; //Function 4
};

i) In Object Oriented Programming, what are Function 1 and Function 4


combined together referred as? Write the definition of function 4.

ii) What is the difference between the following statements?


Stream S(11,”Science”,8700);
Stream S=Stream(11,”Science”,8700);

c. Define a class Customer with the following specifications. [4]

Private Members :
Customer_no integer
Customer_name char (20)
Qty integer
Price, TotalPrice, Discount, Netprice float
Member Functions:
Public members:
* A constructer to assign initial values of Customer_no as
111,Customer_name as “Leena”, Quantity as 0 and Price, Discount and
Netprice as 0.
*Input( ) – to read data members(Customer_no, Customer_name, Quantity
and Price) call Caldiscount().
* Caldiscount ( ) – To calculate Discount according to TotalPrice and
NetPrice
TotalPrice = Price*Qty
TotalPrice >=50000 – Discount 25% of TotalPrice
TotalPrice >=25000 and TotalPrice <50000 - Discount 15% of TotalPrice
TotalPrice <250000 - Discount 10% of TotalPrice
Netprice= TotalPrice-Discount
*Show( ) – to display Customer details.

d. Answer the questions (i) to (iv) based on the following code: [4]

class AC
{
char Model[10];
char Date_of_purchase[10];
char Company[20];
public( );
AC( );
void entercardetail( );
void showcardetail( );
};
class Accessories : protected AC
{
protected:
char Stabilizer[30];
char AC_cover[20];
public:
float Price;
Accessories( );
void enteraccessoriesdetails( );
void showaccessoriesdetails( );
};
class Dealer : public Accessories
{
int No_of_dealers;
char dealers_name[20];
int No_of_products;
public:
Dealer( );
void enterdetails( );
void showdetails( );
};

(i) How many bytes will be required by an object of class Dealer and class
Accessories?

(ii) Which type of inheritance is illustrated in the above c++ code? Write the base
class and derived class name of class Accessories.

(ii) Write names of all the members which are accessible from the objects of
class Dealer.

(iv) Write names of all the members accessible from member functions of class
Dealer.

Q3a) An array T[-1..35][-2..15] is stored in the memory along the row with each
element occupying 4 bytes. Find out the base address and address of element
T[20][5], if an element T[2][2] is stored at the memory location 3000. Find the
total number of elements stored in T and number of bytes allocated to T
[3]
b. Write a function SORTSCORE() in C++ to sort an array of structure IPL in
descending order of score using selection sort .
[3]
Note : Assume the following definition of structure IPL.
struct IPL
{
int Score;
char Teamname[20];
};

c. Write member functions to perform POP and PUSH operations in a


dynamically allocated stack containing the objects of the following structure:
[4]
struct Game
{ char Gamename[30];
int numofplayer;
Game *next; };

d. Write a function in C++ to print the sum of all the non-negative elements
present on both the diagonal of a two dimensional array passed as the argument
to the function. [2]

e. Evaluate the following postfix expression. Show the status of stack after
execution of each operation separately:

2,13, + , 5, -,6,3,/,5,*,< [2]

Q4. a. Write the command to place the file pointer at the 10th and 4th record
starting position using seekp() or seekg() command. File object is ‘file’ and record
name is ‘STUDENT’. [1]

b. Write a function in C++ to count and display the no of three letter words in
the file “VOWEL.TXT”. [2]
Example:
If the file contains:
A boy is playing there. I love to eat pizza. A plane is in the sky.
Then the output should be: 4
c. Given the binary file CAR.Dat, containing records of the following class CAR
type: [3]
class CAR
{
int C_No;
char C_Name[20];
float Milage;
public:
void enter( )
{
cin>> C_No ; gets(C_Name) ; cin >> Milage;
}
void display( )
{
cout<< C_No ; cout<<C_Name ; cout<< Milage;
}
int RETURN_Milage( )
{
return Milage;
}
};

Write a function in C++, that would read contents from the file CAR.DAT and
display the details of car with mileage between 100 to 150.

Section B (Python)

Q1.a) How is a static method different from an instance method? [2]

b) Name the function / method required for [1]

i) Finding second occurrence of m in madam.


ii) get the position of an item in the list

c) Rewrite the following python code after removing all syntax error(s). Underline
the corrections done. [2]

def main():
r = raw-input(‘enter any radius : ‘)
a = pi * math.pow(r,2)
print “ Area = “ + a

d) Give the output of following with justification [2]


x=3
x+= x-x
print x

e) What will be printed, when following python code is executed [3]


class person:
def __init__(self,id):
self.id = id
arjun = person(150)
arjun.__dict__[‘age’] = 50
print arjun.age + len(arjun.__dict__)

Justify your answer.


f) What are the possible outcome(s) expected from the following python code?
Also specify maximum and minimum value, which we can have. [2]

def main():
p = 'MY PROGRAM'
i=0
while p[i] != 'R':
l = random.randint(0,3) + 5
print p[l],'-',
i += 1
i) R - P - O - R -
ii) P - O - R - Y -
iii) O -R - A - G -
iv) A- G - R - M -

Q2. a) How data encapsulation and data abstraction are implemented in python,
explain with example. [2]

b) What will following python code produce, justify your answer [2]
x=5
y=0
print ‘A’
try :
print ‘B’
a=x/y
print ‘C’
except ZerorDivisionError:
print ‘F’
except :
print ‘D’

c) Write a class customer in python having following specifications [4]

Instance attributes:

customernumber - numeric value


customername - string value
price, qty, discount, totalprice, netprice - numeric value
methods :

init() to assign initial values of customernumber as 111, customername as


“Leena”, qty as 0 and price, discount & netprice as 0.
caldiscount ( ) – To calculate discount, totalprice and netprice
totalprice = price * qty
discount is 25% of totalprice, if totalprice >=50000
discount 15% of totalprice, if totalprice >=25000 and totalprice <50000
discount 10% of totalprice, if totalprice <250000
netprice= totalprice - discount

input() – to read data members customername, customernumbar, price, qty and


call caldiscount() to calculate discount, totalprice and netprice.
show( ) – to display Customer details.

d) What are the different ways of overriding function call in derived class of
python ? Illustrate with example. [2]

e) Write a python function to find sum of square-root of elements of a list. List is


received as argument, and function returns the sum. Ensure that your function is
able to handle various situations viz. list containing numbers & strings, module
required is imported etc. [2]

Q3. a) What will be the status of following list after third pass of bubble sort and
third pass of selection sort used for arranging elements in ascending order?
40, 67, -23, 11, 27, 38, -1 [3]

b) Write a python function to search for a value in the given list using binary
search method. Function should receive the list and value to be searched as
argument and return 1 if the value is found 0 otherwise. [2]

c) Define stack class in python to operate on stack of numbers. [4]

d) Write a python function using yield statement to generate prime numbers till
the value provided as parameter to it. [3]

e) Evaluate the following postfix expression. Show the status of stack after
execution of each operation separately:
2,13, + , 5, -,6,3,/,5,*,< [2]

Q4.a) How is method write() different from writelines() in python? [1]

b) Given a pickled file - log.dat, containing list of strings. Write a python function
that reads the file and looks for a line of the form

Xerror: 0.2395

whenever such line is encountered, extract the floating point value and compute
the total of these error values. When you reach end of file print total number of
such error lines and average of error value. [3]

c) Given a text file car.txt containing following information of cars


carNo, carname, milage. Write a python function to display details of all those
cars whose milage is from 100 to 150. [2]

Section C
Q5. a. Define degree and cardinality. Based upon given table write degree and
cardinality. [2]

PATIENTS

PatNo PatName Dept DocID

1 Leena ENT 100

2 Surpreeth Ortho 200

3 Madhu ENT 100

4 Neha ENT 100

5 Deepak Ortho 200

b. Write SQL commands for the queries (i) to (iv) and output for (v) & (viii) based

on a table COMPANY and CUSTOMER [6]

COMPANY
CID NAME CITY PRODUCTNAME

111 SONY DELHI TV

222 NOKIA MUMBAI MOBILE

333 ONIDA DELHI TV

444 SONY MUMBAI MOBILE

555 BLACKBERRY MADRAS MOBILE

666 DELL DELHI LAPTOP

CUSTOMER
CUSTID NAME PRICE QTY CID

101 Rohan Sharma 70000 20 222

102 Deepak Kumar 50000 10 666

103 Mohan Kumar 30000 5 111

104 Sahil Bansal 35000 3 333


105 Neha Soni 25000 7 444

106 Sonal Aggarwal 20000 5 333

107 Arjun Singh 50000 15 666

(i) To display those company name which are having prize less than 30000.
(ii) To display the name of the companies in reverse alphabetical order.
(iii) To increase the prize by 1000 for those customer whose name starts with ‘S’
(iv) To add one more column totalprice with decimal(10,2) to the table customer
(v) SELECT COUNT(*) ,CITY FROM COMPANY GROUP BY CITY;
(vi) SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10 ;
(vii) SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
(viii) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY,CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;

Q6. a) State and define principle of Duality. Why is it so important in Boolean


Algebra? [2]

b) Write the equivalent boolean expression for the following logic circuit [2]

c) Write Product Of Sum expression of the function F (a,b,c,d) from the given
truth table [1]

a b c d F

0 0 0 0 0
0 0 0 1 0
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 1
1 0 1 1 1
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 1

d) Obtain the minimal SOP form for the following boolean expression using K-
Map.
F(w,x,y,z) = (0,2,3,5,7,8,10,11,13,15) [3]

Q7.a.Give any two advantage of using Optical Fibres. [1]

b. Indian School, in Mumbai is starting up the network between its different


wings. There are Four Buildings named as SENIOR, JUNIOR, ADMIN and
HOSTEL as shown below.: [4]

SENIOR

JUNIOR

ADMIN

HOSTEL

The distance between various buildings is as follows:


ADMIN TO SENIOR 200m
ADMIN TO JUNIOR 150m
ADMIN TO HOSTEL 50m
SENIOR TO JUNIOR 250m
SENIOR TO HOSTEL 350m
JUNIOR TO HOSTEL 350m

Number of Computers in Each Building


SENIOR 130
JUNIOR 80
ADMIN 160
HOSTEL 50

(b1) Suggest the cable layout of connections between the buildings.


(b2) Suggest the most suitable place (i.e. building) to house the server of this
School, provide a suitable reason.
(b3) Suggest the placement of the following devices with justification.
· Repeater
· Hub / Switch
(b4) The organization also has Inquiry office in another city about 50-60 Km
away in Hilly Region. Suggest the suitable transmission media to interconnect to
school and Inquiry office out of the following .

· Fiber Optic Cable


· Microwave
· Radio Wave

c. Identify the Domain name and URL from the following. [1]
http://www.income.in/home.aboutus.hml
d. What is Web Hosting? [1]
e. What is the difference between packet & message switching? [1]
f. Define firewall. [1]
g. Which protocol is used to creating a connection with a remote machine? [1]
Sample Question Paper – Set II
Computer Science (083)
Class- XII (2015-16)
Time: 3hrs M.M: 70
Instructions:
i. All Questions are Compulsory.
ii. Programming Language: Section A : C++
iii. Programming Language: Section B: Python
iv. Answer either Section A or B, and Section C is compulsory
Section : A (C++)
Q1 a. Define Macro with suitable example. 2

b. Which C++ header file (s) will be included to run /execute the following C++ code? 1
void main( )
{ int Last =26.5698742658;
cout<<setw(5)<<setprecision(9)<<Last; }

c. Rewrite the following program after removing any syntactical errors. Underline each
correction made. 2
#include<iostream.h>
void main( )
int A[10];
A=[3,2,5,4,7,9,10];
for( p = 0; p<=6; p++)
{ if(A[p]%2=0)
int S = S+A[p]; }
cout<<S; }
d. Find the output of the following C++ program: 2
#include<iostream.h>
void repch(char s[])

1
{
for (int i=0;s[i]!='\0';i++)
{
if(((i%2)!=0) &&(s[i]!=s[i+1]))
{
s[i]='@';
}
else if (s[i]==s[i+1])
{
s[i+1]='!';
i++;
}
}
}
void main()
{
char str[]="SUCCESS";
cout<<”Original String”<<str
repch(str);
cout<<"Changed String"<<str;
}
e. Find the output of the following : 3
#include<iostream.h>
void switchover(int A[ ],int N, int split)
{
for(int K = 0; K<N; K++)
if(K<split)
A[K] += K;
else
A[K]*= K;
}

2
void display(int A[ ] ,int N)
{
for(int K = 0; K<N; K++)
(K%2== 0) ?cout<<A[K]<<"%" : cout<<A[K]<<endl;
}
void main( )
{ int H[ ] = {30,40,50,20,10,5};
switchover(H,6,3);
display(H,6);
}

f. Observe the following C++ code and find out , which out of the given options i) to iv) are the
expected correct output.Also assign the maximum and minimum value that can be assigned to
the variable ‘Go’. 2
void main()
{ int X [4] ={100,75,10,125};
int Go = random(2)+2;
for (inti = Go; i< 4; i++)
cout<<X[i]<<”$$”;

i. 100$$75 ii. 75$$10$$125$$ iii. 75$$10$$ iv.10$$125$

Q2a. Differentiate between data abstraction and data hiding. 2

b. Answer the questions (i) and (ii) after going through the following class : 2
class Exam
{
int Rollno;
char Cname[25];
float Marks ;
public :
Exam( ) //Function 1
{
Rollno = 0 ;
Cname=””;
Marks=0.0;

3
}
Exam(int Rno, char candname) //Function 2
{
Rollno = Rno ;
strcpy(Cname,candname);

}
~Exam( ) //Function 3
{
cout << “Result will be intimated shortly” << endl ;
}
void Display( ) //Function 4
{
cout << “Roll no :”<<Rollno;
cout<<”Name :” <<Cname;
cout <<” Marks:”<<Marks;
}
};
(i)Which OOP concept does Function 1 and Function 2 implement.Explain?
(ii)What is Function 3 called? When will it be invoked?
c. Define a class Candidate in C++ with the following specification : 4
Private Members :
A data members Rno(Registration Number) type long
A data member Cname of type string
A data members Agg_marks (Aggregate Marks) of type float
A data members Grade of type char
A member function setGrade () to find the grade as per the aggregate marks
obtained by the student. Equivalent aggregate marks range and the respective grade as shown
below.
Aggregate Marks Grade
>=80 A
Less than 80 and >=65 B

4
Less than 65 and >=50 C
Less than 50 D
Public members:
A constructor to assign default values to data members:
Rno=0,Cname=”N.A”,Agg_marks=0.0
A function Getdata () to allow users to enter values for Rno. Cname, Agg_marks and call
function setGrade () to find the grade.
A function dispResult( ) to allow user to view the content of all the data members.

d. Give the following class definition answer the question that is follow: 4
class University
{
char name [20];
protected :
char vc[20];
public :
void estd();
void inputdata();
void outputdata();
}
class College : protected University
{ int regno;
protected
char principal()
public :
int no_of_students;
void readdata();
void dispdata ( );
};
class Department : public College
char name[20];

5
char HOD[20];
public :
void fetchdata(int);
void displaydata( ); }
i). Name the base class and derived class of college. 1
ii) Name the data member(s) that can be accessed from function displaydata().
iii)What type of inheritance is depicted in the above class definition?
iv) What will be the size of an object (in bytes) of class Department?
Qs. 3a. An integer array A [30][40] is stored along the column in the memory. If the element
A[20][25] is stored at 50000, find out the location of A[25][30]. 3
b. Write the definition of functions for the linked implemented queue containing passenger
informationas follows: 4
struct NODE
{ int Ticketno;
char PName[20];
NODE * NEXT; };
class Queueofbus
{ NODE *Rear, *Front;
public:
Queueofbus()
{ Rear = NULL;
Front = NULL; };
void Insert();
void Delete();
~Queueofbus()
{ cout<<"Object destroyed"; }
};

6
c. Write a function to sort any array of n elements using insertion sort . Array should be passed
as argument to the function. 3
d. Write a function NewMAT(int A[][],int r,int c ) in C++, which accepts a 2d array of integer and
its size as parameters divide all those array elements by 6 which are not in the range 60 to
600(both values inclusive) in the 2d Array . 2
e.Evaluate the following postfix expression using stack and show the contents after execution of
each Operations:470,5,4,^,25,/,6,* 2
Q4a.Consider a file F containing objects E of class Emp. 1
i)Write statement to position the file pointer to the end of the file
ii)Write statement to return the number of bytes from the beginning of the file to the
current position of the file pointer.
b. Write a function RevText() to read a text file “ Input.txt “ and Print only word starting with ‘I’
in reverse order . 2
Example: If value in text file is: INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY
c. Write a function in C++ to search and display details, whose destination is “Chandigarh”from
binary file “Flight.Dat”. Assuming the binary file is containing the objects of the
following class: 3
class FLIGHT
{ int Fno; // Flight Number
char From[20]; // Flight Starting Point
char To[20]; // Flight Destination
public:
char * GetFrom ( ); { return from; }
char * GetTo( ); { return To; }
void input() { cin>>Fno>>; gets(From); get(To); }
void show( ) { cout<<Fno<< “:”<<From << “:” <<To<<endl; }
};
Section : B (Python)
Q1. a. List one similarity and one difference between List and Dictionary datatype 2

7
b. Observe the following Python functions and write the name(s) of the module(s) to which they
belong: 1
a. uniform() b. findall()
c. Rewrite the following Python program after removing all the syntactical errors (if
any),underlining each correction.: 2
def checkval:
x = raw_input(“Enter a number”)
if x % 2 = 0 :
print x,”is even”
else if x<0 :
print x,”should be positive”
else ;
print x,”is odd”

def checkval():
x = raw_input(“Enter a number”)
if x % 2 = = 0 :
print x,”is even”
elif x<0 :
print x,”should be positive”
else :
print x,”is odd”

d. Find the output of the following Python program: 3


def makenew(mystr):
newstr = " "
count = 0
for i in mystr:
if count%2 !=0:
newstr = newstr+str(count)
else:
if islower(i):
newstr = newstr+upper(i)
else:
newstr = newstr+i

8
count +=1
newstr = newstr+mystr[:1]
print "The new string is :",newstr
makenew(“sTUdeNT")
e. Find the output of the following program 2
def calcresult () :
i=9
while i> 1 :
if (i % 2 == 0):
x = i%2
i = i-1
else :
i = i-2
x=i
print x**2
f. Observe the following Python code and find out , which out of the given options i) to iv) are
the expected correct output(s).Also assign the maximum and minimum value that can be
assigned to the variable ‘Go’. 2
import random
X =[100,75,10,125]
Go = random.randint(0,3)
for i in range(Go):
print X[i],"$$",
i. 100$$75$$10 ii. 75$$10$$125$$iii. 75$$10$$ iv.10$$125$$100

Q2 a. Discuss the strategies employed by python for memory allocation? 2


b. Answer the questions (i) and (ii) after going through the following class definition: 2
class Toy :
tid =0;
tcat = “ “
def __init__(self):// Function1

9
..................................... // Blank 2
i. Explain relevance of Function 1.
ii. a. Fill in the blank2 with a statement to create object of the class TOY.
b. Write statement to check whether tprice is an attribute of class TOY.

c. Define a class Train in PYTHON with following description: 4


Data Members

src of type string


Tnm of type string
dest of type string
charges of float

• A member function Getdata to assign the following values for Charges


Dest Charges
Mumbai 1000
Chennai 2000
Kolkatta 2500
Public members
• A constructor to initialize the data members.
• A function InputData() to allow the user to enter the values
• A function displaydata() to display all and call getdata function

d. Observe the following class definition and answer the question that follow: 2
class ParentClass(objects):
def__init__(self)
self,x = 1
self.y = 10
def print(self):
print(self.x, self.y)
class ChildClass(ParentClass):
def__init__(self):
super(ChildClass, self).init_() # Line 1
self,x = 2
self.y = 20
c = ChildClass()
c.print()

a. Explain the relevance of Line1.


b. What type of inheritance is being demonstrated in the above code?

e. Write a user defined function findname(name) where name is an argument in Python to delete
phone number from a dictionary phonebook on the basis of the name ,where name is the
key. 2

10
Qs. 3a.Explain try..except…else … with the help of user defined function def divide(x, y)which
raises an error when the denominator is zero while dividing x by y and displays the quotient
otherwise. 3
b. Write a user defined function arrangelements(X), that accepts a list X of integers and sets all
the negative elements to the left and all positive elements to the right of the list.
Eg: if L =[1,-2,3,4,-5,7] , the output should be: [-2,-5,3,4,7] 3
c. Consider the following class definition :- 3
class book ():
bk = []
def _ init _ (self, bno):
self .bno = bno
def addbook (self):
……………
def removebook (self):
……………
The class book is implemented using Queue. Keeping the same in mind, complete the function
definitions for adding a book addbook() and deleting a book removebook() .
d. Write a python function generatefibo(n) where n is the limit using a generator function
Fibonacci (max) where max is the limit n that produces Fibonacci series.. 3

e. Evaluate the following postfix using stack & show the content of the stack after the execution
of each: 20, 4, +, 3, -, 7, 1 2

Q4a. Consider the following code : 1


f = open ("mytry", "w+")
f.write ("0123456789abcdef")
f.seek (-3,2) //1
printf.read(2) //2

Explain statement 1 and give output of 2


b. Write a user defined function in Python that displays the number of lines starting with ‘H’ in
the file Para.txt.Eg: if the file contains: 2

11
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

Then the line count should be 2.


c. Consider a binary file Employee.dat containing details such as empno:ename:salary (separator
‘ :’). Write a python function to display details of those employees who are earning between
20000 and 40000.(both values inclusive) 3

Section : C
Q 5. a. Differentiate between cardinality and degree of a table with the help of an example. 2
b) Consider the following tables FACULTY and COURSES. Write SQL commands for the
statements (i) to (v) and give outputs for SQL queries (vi) to (vii) 6
FACULTY
F_ID Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000
COURSES
C_ID F_ID Cname Fees
C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
i) To display details of those Faculties whose salary is greater than 12000.
ii) To display the details of courses whose fees is in the range of 15000 to 50000 (both
values included).
iii) To increase the fees of all courses by 500 of “System Design” Course.
iv) To display details of those courses which are taught by ‘Sulekha’ in descending order of
courses.
v) Select COUNT(DISTINCT F_ID) from COURSES;
vi) Select MIN(Salary) from FACULTY,COURSES where COURSES.F_ID =
FACULTY.F_ID;
Q6.a. State and Verify Absorption law algebraically. 2
b. Draw a logic circuit for the following Boolean expression: A.B+C.D’. 2

12
c. Write the SOP form of a Boolean function F, which is represented in a truth table as follows:
1
A B C F
0 0 0 0
0 0 1 1
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. Obtain a simplified from for a Boolean expression: 3
F (U, V, W, Z) = II (0, 1, 3, 5, 6, 7, 15)

Q 7.a Write any 1 advantage and 1 disadvantage of Bus topology. 1

b. SunRise Pvt. Ltd. is setting up the network in the Ahmadabad. There are four departments
named as MrktDept, FunDept, LegalDept, SalesDept. 4

SalesDept
MrktDept

Legal Dept Fun Dept

13
Distance between various buildings is given as follows:

MrktDept to FunDept 80 m

MrktDept to LegalDept 180m

MrktDept to SalesDept 100 m

LegalDept to SalesDept 150 m

LegalDept to FunDept 100 m

FunDept to SalesDept 50 m

Number of Computers in the buildings:

MrktDept 20

LegalDept 10

FunDept 08

SalesDept 42

i) Suggest a cable layout of connections between the Departments and specify topology.
ii) Suggest the most suitable building to place the server with a suitable reason.
iii) Suggest the placement of i) modem ii) Hub /Switch in the network.
iv) The organization is planning to link its sale
counter situated in various part of the same city/ which type of network out of LAN,
WAN, MAN will be formed? Justify.
c. Name the protocol 1
i. Used to transfer voice using packet switched network.
ii.Used for chatting between 2 groups or between 2 individuals.
d. What is an IP Address? 1
e. What is HTTP? 1
f. Explain the importance of Cookies. 1
g. How is 4G different from 3G? 1

14
SQP - Computer Science (Code: 083)
Class XII (2016-17)
Time: 3Hrs. MM: 70
Instructions:
i. All Questions are Compulsory.
ii. Programming Language : Section – A : C++
iii. Programming Language : Section – B : Python
iv. Answer either Section A or B and Section C is compulsory
Section – A
1 (a) Explain conditional operator with suitable example? 2
(b) Which C++ header file(s) are essentially required to be included to 1
run/execute the following C++ code :
void main()
{
char *word1="Hello",*word2="Friends";
strcat(word1,word2);
cout<<word1;
}
(c) Rewrite the following program after removing the syntactical errors 2
(if any). Underline each correction.

#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<stdio.h>
class product
{
int product_code,qty,price;
char name[20];
public:
product(){
product_code=0;qty=0;price=0;
name=NULL;
}
void entry()
{
cout<<"\n Enter code,qty,price";
cin>>product_code>>qty>>price;
gets(name);
}
void tot_price() {return qty*price;}
};
void main()
{
p product;
p.entry();
cout<<tot_price();
}
(d) Write the output of the following C++ program code: 2
Note: Assume all required header files are already being included in
the program.
void change(int *s)
{
for(int i=0;i<4;i++)
{
if(*s<40)
{
if(*s%2==0)
*s=*s+10;
else
*s=*s+11;
}
else
{
if(*s%2==0)
*s=*s-10;
else
*s=*s-11;
}
cout<<*s<<" ";
s++;
}
}
void main()
{
int score[]={25,60,35,53};
change(score);
}
(e) Write the output of the following C++ program code: 3
Note: Assume all required header files are already being included in
the program.
class seminar
{
char topic[30];
int charges;
public:
seminar()
{
strcpy(topic,"Registration");
charges=5000;
}
seminar(char t[])
{
strcpy(topic,t);
charges=5000;
}
seminar(int c)
{
strcpy(topic,"Registration with Discount");
charges=5000-c;
}
void regis(char t[],int c)
{
strcpy(topic,t);
charges=charges+c;
}
void regis(int c=2000)
{
charges=charges+c;
}
void subject(char t[],int c)
{
strcpy(topic,t);
charges=charges+c;
}
void show()
{
cout<<topic<<"@"<<charges<<endl;
}
};
void main()
{
seminar s1,s2(1000),s3("Genetic Mutation"),s4;
s1.show();
s2.show();
s1.subject("ICT",2000);
s1.show();
s2.regis("Cyber Crime",2500);
s2.show();
s3.regis();
s3.show();
s4=s2;
s4.show();
getch();
}
(f) Observe the following program carefully and attempt the given 2
questions:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
randomize();
char courses[][10]={"M.Tech","MCA","MBA","B.Tech"};
int ch;
for(int i=1;i<=3;i++)
{
ch=random(i)+1;
cout<<courses[ch]<<"\t";
}
getch();
}
I. Out of all the four courses stored in the variable courses, which
course will never be displayed in the output and which course will
always be displayed at first in the output?
II. Mention the minimum and the maximum value assigned to the
variable ch?
2 (a) What do you understand by Function overloading or Functional 2
polymorphism? Explain with suitable example.
(b) Answer the questions(i) and (ii) after going through the following 2
class:
class planet
{
char name[20];char distance[20];
public:
planet() //Function 1
{
strcpy(name, "Venus");
strcpy(distance,"38 million km");
}
void display(char na[],char d[]) //Function 2
{
cout<<na<<"has "<<d<<" distance from Earth"<<endl;
}
planet(char na[], char d[]) //Function 3
{
strcpy(name,na);
strcpy(distance,d);
}
~planet() //Function 4
{
cout<<"Planetarium time over!!!"<<endl;
}
};
I. What is Function 1 referred as? When will it be executed?
II. Write suitable C++ statement to invoke Function 2.
(c) Define a class DanceAcademy in C++ with following description: 4
Private Members
● Enrollno of type int
● Name of type string
● Style of type string
● Fee of type float
● A member function chkfee( ) to assign the value of fee
variable according to the style entered by the user
according to the criteria as given below:

Style Fee

Classical 10000

Western 8000

Freestyle 11000

Public Members
● A function enrollment() to allow users to enter values
for Enrollno,Name, Style and call function chkfee()to
assign value of fee variable according to the Style
entered by the user.
● A function display() to allow users to view the details of
all the data members.
(d) Answer the questions (i) to (iv) based on the following: 4
class indoor_sports
{
int i_id;
char i_name[20];
char i_coach[20];
protected:
int i_rank,i_fee;
void get_ifee();
public:
indoor_sports();
void iEntry();
void ishow();
};
class outdoor_sports
{
int o_id;
char o_name[20];
char o_coach[20];
protected:
int orank,ofee;
void get_ofee();
public:
outdoor_sports();
void oEntry();
void oshow();
};
class sports:public indoor_sports,protected outdoor_sports
{
char rules[20];
public:
sports();
void registration();
void showdata();
};
(i) Name the type of inheritance illustrated in the above C++ code.
(ii) Write the names of all the members, which are accessible from
the objects belonging to class outdoor_sports.
(iii) Write the names of all the member functions, which are
accessible from the member function of class sports.
(iv) What will be the size of the object belonging to class
indoor_sports?
3 (a) Write the definition of a function grace_score (int score [], int size) in 3
C++, which should check all the elements of the array and give an
increase of 5 to those scores which are less than 40.

Example: if an array of seven integers is as follows:


45, 35, 85, 80, 33, 27, 90
After executing the function, the array content should be changed as
follows:
45, 40, 85, 80, 38, 32, 90
(b) An array P[30][20] is stored along the column in the memory with 3
each element requiring 2 bytes of storage. If the base address of the
array P is 26500, find out the location of P[20][10].
(c) Write the definition of a member function push() for a class Library in 4
C++ to insert a book information in a dynamically allocated stack of
books considering the following code is already written as a part of
the program:
struct book
{
int bookid;
char bookname[20];
book *next;
};
class Library
{
book *top;
public:
Library()
{
top=NULL;
}
void push();
void pop();
void disp();
~Library();
};
(d) Write a user-defined function swap_row(int ARR[ ][3],int R,int C) in 2
C++ to swap the first row values with the last row values:

For example if the content of the array is:

10 20 30

40 50 60

70 80 90

Then after function call, the content of the array should be:

70 80 90
10 20 30

(e) Evaluate the following POSTFIX expression. Show the status of 2


Stack after execution of each operation separately:
45, 45, +, 32, 20, 10, /, -,*
4 (a) Find the output of the following C++ code considering that the binary 1
file sp.dat already exists on the hard disk with 2 records in it.
class sports
{
int id;
char sname[20];
char coach[20];
public:
void entry();
void show();
void writing();
void reading();
}s;

void sports::reading()
{
ifstream i;
i.open("sp.dat");
while(1)
{
i.read((char*)&s,sizeof(s));
if(i.eof())
break;
else
cout<<"\n"<<i.tellg();
}
i.close();
}
void main()
{
s.reading();
}
(b) Write a user defined function word_count() in C++ to count how 2
many words are present in a text file named “opinion.txt”.
For example, if the file opinion.txt contains following text:

Co-education system is necessary for a balanced society. With


co-education system, Girls and Boys may develop a feeling of
mutual respect towards each other.

The function should display the following:


Total number of words present in the text file are: 24

(c) Write a function display () in C++ to display all the students who have 3
got a distinction(scored percentage more than or equal to 75) from a
binary file “stud.dat”, assuming the binary file is containing the objects
of the following class:
class student
{
int rno;
char sname [20];
int percent;
public:
int retpercent()
{
return percent;
}
void getdetails()
{
cin>>rno;
gets(sname);
cin>>percent;
}
void showdetails()
{
cout<<rno;
puts(sname);
cout<<percent;
}
};
Section - B (Python)
1 (a) Carefully observe the following python code and answer the questions 2
that follow:

On execution the above code produces the following output.


6
3
Explain the output with respect to the scope of the variables.
(b) Name the modules to which the following functions belong: 1
a. uniform() b. fabs()
(c) Rewrite the following code after removing the syntactical errors (if 2
any). Underline each correction.

(d) Observe the following Python code carefully and obtain the output, 2
which will appear on the screen after execution of it.
(e) What output will be generated when the following Python code is 3
executed?

(f) Observe the following program and answer the questions that follow: 2
import random

a. What is the minimum and maximum number of times the loop


will execute?
b. Find out, which line of output(s) out of (i) to (iv) will not be
expected from the program?
i. 0#1
ii. 1#2
iii. 2#3
iv. 3#4
2 a Explain the two strategies employed by Python for memory 2
allocation.
b Observe the following class definition and answer the questions that 2
follow:
i. Write statement to invoke Function 1.
ii. On Executing the above code , Statement 2 is giving an error
explain.
c Define a class PRODUCT in Python with the following specifications 4
Data members:
Pid – A string to store productid.
Pname - A string to store the name of the product.
Pcostprice – A decimal to store the cost price of the product
Psellingprice – A decimal to store Selling Price
Margin - A decimal to be calculated as Psellingprice - Pcostprice
Remarks - To store”Profit” if Margin is positive else “Loss” if
Margin is negative
Member Functions:
● A constructor function to initialize All the data members with
valid default values.
● A method SetRemarks() that assigns Margin as
Psellingprice - Pcostprice and sets Remarks as mentioned
below:

Margin Remarks

<0 ( negative) Loss


>0(positive) Profit

● A method Getdetails() to accept values for


Pid,Pname,Pcostprice,Psellingprice and invokes SetRemarks()
method.
- A method Setdetails() that displays all the data members.
d Answer the questions (i) to (iv) based on the following: 4
i. Which type of Inheritance is demonstrated in the above code?
ii. Explain Statement 1 and 2.
iii. Name the methods that are overridden along with their class name.
iv. Fill Blank1 with a statement to display variable category of class
Brand.
3 a Consider the following unsorted list 3
95 79 19 43 52 3
Write the passes of bubble sort for sorting the list in ascending order
till the 3rd iteration.
b Kritika was asked to accept a list of even numbers but she did not put 3
the relevant condition while accepting the list of numbers. You are
required to write a code to convert all the odd numbers into even by
multiplying them by 2.
c Aastha wants to create a program that accepts a string and display the 4
characters in the reverse order in the same line using a Stack. She has
created the following code , help her by completing the definitions on
the basis of requirements given below :
class mystack:
def __init__(self):
self.mystr= ________________ # Accept a string
self.mylist =________________ # Convert mystr to a list
# Write code to display while removing elements from the stack.
def disp(self):
:
:

d Write a generator function generatesq() that displays the squareroots of 2


numbers from 100 to n where n is passed as an argument .
e Evaluate the following Postfix expression: 2
20,10,-,15,3,/,+,5,*
4 a Observe the following code and answer the questions that follow: 1
File = open("Mydata","a")
_____________________ #Blank1
File.close()
i. What type (Text/Binary) of file is Mydata?
ii. Fill the Blank 1 with statement to write “ABC” in the file “Mydata”

b A text file “Quotes.Txt” has the following data written in it: 2

Living a life you can be proud of


Doing your best
Spending your time with people and activities that are important to you
Standing up for things that are right even when it’s hard
Becoming the best version of you

Write a user defined function to display the total number of words


present in the file.

c Consider the following class declaration and answer the question that 3
follows:

A
nuj has been asked to display all the students who have scored less than
40 for Remedial Classes.
Write a user defined function to display all those students who have
scored less than 40 from the binary file “Student.dat” assuming it stores
all the object of the class Student mentioned above.
Section – C
5 (a) Observe the table ‘Club’ given below: 2

Club
Member_id Member_Name Address Age Fee
M002 Nisha Gurgaon 19 3500

M003 Niharika New Delhi 21 2100

M004 Sachin Faridabad 18 3500

i. What is the cardinality and degree of the above given table?


ii. If a new column contact_no has been added and three more
members have joined the club then how these changes will affect the
degree and cardinality of the above given table.
(b) Write SQL commands for the queries (i) to (iv) and output for (v) to 6
(viii) based on the tables ‘Watches’ and ‘Sale’ given below.

Watches
Watchid Watch_Name Price Type Qty_Store
W001 HighTime 10000 Unisex 100
W002 LifeTime 15000 Ladies 150
W003 Wave 20000 Gents 200
W004 HighFashion 7000 Unisex 250
W005 GoldenTime 25000 Gents 100

Sale
Watchid Qty_Sold Quarter
W001 10 1
W003 5 1
W002 20 2
W003 10 2
W001 15 3
W002 20 3
W005 10 3
W003 15 4
i. To display all the details of those watches whose name ends with
‘Time’

ii. To display watch’s name and price of those watches which have price
range in between 5000-15000.

iii. To display total quantity in store of Unisex type watches.

iv. To display watch name and their quantity sold in first quarter.

v. select max(price), min(qty_store) from watches;


vi. select quarter, sum(qty_sold) from sale group by quarter;

vii. select watch_name,price,type from watches w, sale s where


w.watchid!=s.watchid;

viii. select watch_name, qty_store, sum(qty_sold), qty_store-


sum(qty_sold) “Stock” from watches w, sale s where
w.watchid=s.watchid group by s.watchid;

6 (a) Correct the following boolean statements: 2


1. X+1 = X
2. (A')'=A'
3. A+A'=0
4. (A+B)' = A.B

(b) Draw the equivalent logic circuit for the following Boolean 1
expression:
(A.B)+C
(c) Write the POS form of a Boolean Function F, which is represented in 2
a truth tale as follows:

P Q R F

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

(d) Reduce the following Boolean Expression using K Map: 3


F(A,B,C,D)=
7 (a) Identify the type of topology on the basis of the following: 2
1. Since every node is directly connected to the server, a large
amount of cable is needed which increases the installation cost
of the network.
2. It has a single common data path connecting all the nodes.
(b) Expand the following: 1
a. VOIP
b. SMTP
(c) Who is a hacker? 1
(d) The following is a 32 bit binary number usually represented as 4 1
decimal values, each representing 8 bits, in the range 0 to 255 (known
as octets) separated by decimal points.
140.179.220.200
What is it? What is its importance?
(e) Daniel has to share the data among various computers of his two 1
offices branches situated in the same city. Name the network (out of
LAN, WAN, PAN and MAN) which is being formed in this process.

(f) Rehaana Medicos Center has set up its new center in Dubai. It has
four buildings as shown in the diagram given below:

Distances between various buildings are as follows:

Accounts to Research Lab 55 m

Accounts to Store 150 m

Store to Packaging Unit 160 m

Packaging Unit to Research Lab 60 m


Accounts to Packaging Unit 125 m

Store to Research Lab 180 m

Number of Computers

Accounts 25

Research Lab 100

Store 15

Packaging Unit 60

As a network expert, provide the best possible answer for the


following queries:
i) Suggest a cable layout of connections between the buildings. 1
ii) Suggest the most suitable place (i.e. buildings) to house the server of this
organization. 1
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch 1
iv) Suggest a system (hardware/software) to prevent unauthorized
1
access to or from the network.
SAMPLE QUESTION PAPER
Subject: Computer Science
Class: XII (2017-18)

Time: 3 Hrs. M.M.:70


Instructions:
(a) All questions are compulsory,
(b) Answer either Section A or Section B:
(i) Section A - Programming Language with C++
(ii) Section B - Programming Language with Python
(c) Section C is compulsory.
SECTION – A (C++)
Q. Part Question Description Marks
No.
Q1. (a) What is the role of a parameter/argument passed in a function? Can a default value be 2
assigned to a parameter(Yes/No)? If yes, justify your answer with the help of a suitable
example otherwise give reason.
(b) Raman suggests Kishan the following header files which are required to be included in 1
the given C++ program. Identify the header files which are wrongly suggested by
Raman.
Program:

Suggested header files:-


1. iostream.h
2. stdio.h
3. conio.h
4. ctype.h

(c) Rewrite the following program after removing the syntactical errors (is any). Underline 2
each correction.

Page No. 1
(d) Write the output of the following C++ program code(assume all necessary header files 2
are included in program):

(e) Write the output of the following C++ program code(assume all necessary header files 3
are included in program):

Page No. 2
(f) Consider the following C++ program code and choose the option(s) which are not 2
possible as output. Also, print the minimum & maximum value of variable Pick during
complete execution of the program.(assume all necessary header files are included in
program):

(a) 5:6:6:6:
(b) 4:7:5:3:
(c) 8:6:1:2:
(d) 7:5:3:1
Q2. (a) What do you mean by Data Abstraction in OOPs? Explain its significance in 2
programming with a suitable example.
(b) Answer the question (i) & (ii) after going through the following code. (assume all 2
necessary header files are included in program):-

Page No. 3
(i) Give the name of the feature of OOP which is implemented by Function 1 &
2 together in the above class Game.
(ii) Anuj made changes to the above class Game and made Function 3 private.
Will he be able to execute the Line 1 successfully given below? Justify.
void main()
{
Game ABC; //Line 1
}
(c) Define a class Bill in OOP with the following specification:- 4
Private members:
1. Bill_no - type long(bill number)
2. Bill_period - type integer(number of months)
3. No_of_calls - type integer(number of mobile calls)
4. Payment_mode - type string(“online” or “offline”)
5. Amount - type float(amount of bill)
6. Calculate_Bill() function to calculate the amount of bill given as per the
following conditions:
Calculation Rate/call
No_of_calls
(in rupees)
<=500 1.0
501-1200 2.0
>1200 4.0

Page No. 4
Also, the value of Amount should be reduced by 5% if Payment_mode is
“online”.

Public members:
1. A member function New_Bill() that will accept the values for Bill_no,
Bill_period, No_of_calls, Payment_mode from the user and invoke
Caluclate_Bill() to assign the value of Amount.
2. A member function Print_Bill() that will display all details of a Bill.
(d) Answer the question from (i) to (iv) based on the given below code(assume all necessary 4
header files are included in program):-

(i) Write name of the class whose constructor is invoked first on the creation of a
new object of class Country.
(ii) Write name of the data members which are accessible through the object of
class Country.

Page No. 5
(iii) List name of the members which are accessible through the member function
“void New_Country()”.
(iv) What will be the size(in bytes) of an object of class Country & State
respectively.
Q3 (a) Write the definition of function named Array_Swap() that will accept an integer array & 3
its size as arguments and the function will interchange/swap elements in such a way that
the first element is swapped with the last element, second element is swapped with the
second last element and son on, only if anyone or both the elements are odd.
E.g. if initially array of seven elements is:
5, 16, 4, 7, 19, 8, 2
After execution of the above function, the contents of the array will be:
2,16, 19, 7, 4, 8, 5
(b) An array A[50][30] is stored along the row in the memory with each element requiring 4 3
bytes of storage. If the element A[10][15] is stored at 21500, then find out the base
address of the array and the memory address of element stored at location A[30][25]?
(c) Write the definition of a member function Q_Insert() for a class Exam_Queue in C++ 4
to insert a new Application information in a dynamically allocated queue whose code is
already given below as a part of the program(assume all necessary header files are
included in program):

(d) Write the definition of a user-defined function REPEAT_ROW(int A[][3],int R, int C) 2


in C++ that will store the elements in the following manner
1. All row elements except the 1st element replaced by the 1st element,
2. All row elements except the 1st & 2nd element replaced by the 2nd element,
3. All row elements except the 1st , 2nd & 3rd element replaced by the 3rd element and

Page No. 6
so on.
For example: if initially the array was:-
5 6 10 2
2 6 9 12
18 14 5 6
Then, the contents of the array after execution of the above function will be:-
5 5 5 5
2 6 6 6
18 14 14 14
(e) Evaluate the following POSTFIX expression. Show the status of Stack after execution of 2
each operation separately:
TRUE, FALSE, OR, NOT, TRUE, FALSE, AND, OR
Q4. (a) Answer the questions (i) & (ii) in the program segment given below for the required task. 1

(i) Write Statement 1 to position the file pointer to the appropriate place so that
the data updation is done for the correct Route.
(ii) Write Statement 2 to perform the write operation so that the updation is done
Page No. 7
in the binary file “ROUTE.DAT”.
(b) Write a user-defined function named Count() that will read the contents of text file 2
named “Report.txt” and count the number of lines which starts with either „I‟ or „M‟.
E.g. In the following paragraph, there are 2 lines starting with „I‟ or „M‟:
“India is the fastest growing economy.
India is looking for more investments around the globe.
The whole world is looking at India as a great market.
Most of the Indians can foresee the heights that India is capable of reaching.”
(c) Consider the following class Item:- 3

Write a function named Change_Item(int Id, float Pr) to modify the price of the item
whose ItemId & new price are passed as an argument.
SECTION – B (Python)
Q1 (a)
Differentiate between break and continue statement with the help of an example.
2
(b) Identify and write the name of the module to which the following functions belong: 1
i. ceil( ) ii. findall()
(c) Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined.

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


Page No. 8
(e) Write the output of the following Python program code: 3

(f) Study the following program and select the possible output(s) from the options (i) to (iv) 2
following it. Also, write the maximum and the minimum values that can be assigned to
the variable Y.

i) 0 : 0
ii) 1 : 6
iii) 2 : 4
iv) 0 : 3
Q2 (a) Explain operator overloading with the help of an example. 2
(b) Observe the following Python code and answer the questions (i) and (ii):

(i) How is data member „count‟ different from data member „Author‟? 1
(ii) Fill in the blanks: 1
B= BOOK()
______________________________ #Write statement to invoke Function 2

Page No. 9
______________________________ #Write statement to invoke Function 3
(c) Define a class COURSE in Python with the following description : 4
Instance Attributes:
REGNO Integer
CNAME String
Score Float
Fees Float
Methods:
 A constructor to assign REGNO as 0, Score and Fees as 0.0
 SetCourse() to assign Course and Fees on the basis of the Score input as
per the following criteria:
Score CNAME Fees
>=9.0 -<=10.0 Clinical Psychology 10000.0
>=8.0 - <9.0 Corporate Counselling 8000.0
>=5.0 - <8.0 Guidance and
Counselling 6000.0
less than 5.0 Not Eligible 0.0

 GETDATA() to input REGNO and Score and invoke SetCourse()


 DISPLAY() to display all the details.

(d) Answer the questions (i) and (ii) based on the following: 4

(i) Explain the relationship between Line 1 , Line 2 and Line 3.


(ii) Predict the output that will be produced on the execution of the following statements :

Page No. 10
Q3 (a) Write the definition of a function Reverse(X) in Python, to display the elements in 2
reverse order such that each displayed element is the twice of the original element
(element * 2) of the List X in the following manner:
Example:
If List X contains 7 integers is as follows:

X[0] X[1] X[2] X[3] X[4] X[5] X[6]


4 8 7 5 6 2 10
After executing the function, the array content should be displayed as follows:
20 4 12 10 14 16 8
(b) Consider the following unsorted list : 3
[22, 54, 12, 90, 55, 78]
Write the passes of selection sort for sorting the list in ascending order till the 3rd
iteration.

(c) Consider the following class Order and do as directed: 4

Blank 1

:
:
i. Fill in the blank 1 with a statement to insert OID in the Queue maintained using List
L.
ii. Complete the definition of delorder() to delete OID from the Queue maintained using
List L, the function should return the OID being deleted or -1 in case the Queue is empty.

d) Write a generator function to generate odd numbers between a and b(including b).Note: a 3
and b are received as an argument by the function.
(e) Evaluate the following postfix expression using a stack. Show the contents of stack after 2
execution of each operation:
10,40,25,-,*,15,4,*,+
Q4. (a) Nancy intends to position the file pointer to the beginning of a text file. Write Python 1
statement for the same assuming F is the File object.
(b) Write a function countmy( )in Python to read the text file “DATA.TXT” and count the
number of times “my” occurs in the file.
For example if the file “DATA.TXT” contains:
2
“This is my website. I have displayed my preferences in the CHOICE section.”
The countmy( ) function should display the output as:
“my occurs 2 times”.
(c) Write a function in python to search and display details of all those students, whose 3
stream is “HUMANITIES” from pickled file “Student.dat”. Assuming the pickled file is
containing the objects of the following class:

Page No. 11
SECTION – C
Q5 (a) Differentiate between DDL & DML. Identify DDL & DML commands from the 2
following:-
(UPDATE, SELECT, ALTER, DROP)
(b) Consider the following relation MobileMaster & MobileStock:- 6
MobileMaster
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 4500 2013-02-12
MB003 Nokia N1100 2250 2011-04-15
MB004 Micromax Unite3 4500 2016-10-17
MB005 Sony XperiaM 7500 2017-11-20
MB006 Oppo SelfieEx 8500 2010-08-21

MobileStock
S_Id M_Id M_Qty M_Supplier
S001 MB004 450 New Vision
S002 MB003 250 Praveen Gallery
S003 MB001 300 Classic Mobile Store
S004 MB006 150 A-one Mobiles
S005 MB003 150 The Mobile
S006 MB006 50 Mobile Centre

Write the SQL query for questions from (i) to (iv) & write the output of SQL command
for questions from (v) to (viii) given below:-
(i) Display the Mobile company, name & price in descending order of their

Page No. 12
manufacturing date,
(ii) List the details of mobile whose name starts with „S‟ or ends with „a‟,
(iii) Display the Mobile supplier & quantity of all mobiles except „MB003‟,
(iv) List showing the name of mobile company having price between 3000 &
5000,
(v) SELECT M_Id, SUM(M_Qty) FROM MobileStock GROUP BY M_Id;
(vi) SELECT MAX(M_Date), MIN(M_Date) FROM MobileMaster;
(vii) SELECT M1.M_Id, M1.M_Name, M2.M_Qty, M2.M_Supplier FROM
MobileMaster M1, MobileStock M2 WHERE M1.M_Id=M2.M_Id AND
M2.M_Qty>=300;
(viii) SELECT AVG(M_Price) FROM MobileMaster;
Q6. (a) State & prove De-Morgan‟s law using truth table. 2
(b) Draw the equivalent logic circuit diagram of the following Boolean expression:- 2
(A‟ + B).C‟
(c) Write the SOP form for the Boolean Function F(X,Y,Z) represented by the given truth 1
table:-
X Y Z F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(d) Reduce the following Boolean expression using K-Map:- 3
F(U,V,W,Z)= π(0,2,5,7,12,13,15)
Q7. (a) A teacher provides “http://www.XtSchool.com/default.aspx” to his/her students to 1
identify the URL & domain name.
(b) Which out of the following does not come under Cyber Crime? 1
(i) Copying data from the social networking account of a person without his/her
information & consent.
(ii) Deleting some files, images, videos, etc. from a friend‟s computer with his consent.
(iii) Viewing & transferring funds digitally from a person‟s bank account without
his/her knowledge.
(iv) Intentionally making a false account on the name of a celebrity on a social
Page No. 13
networking site.
(c) Expand the following:- 1
1. GSM 2. TDMA
(d) What is the significance of cookies stored on a computer? 1
(e) Kabir wants to purchase a Book online and he has placed the order for that book using an 1
e-commerce website. Now, he is going to pay the amount for that book online using his
Mobile, then he needs which of the following to complete the online transaction:-
1. A bank account,
2. Mobile phone which is attached to above bank account,
3. The mobile banking app of the above bank installed on that mobile,
4. Login credentials(UID & Pwd) provided by the bank,
5. Or all of above.
(f) What do you mean by data encryption? For what purpose it is used for? 1
(g) Sanskar University of Himachal Pradesh is setting up a secured network for its campus at
Himachal Pradesh for operating their day-to-day office & web based activities. They are
planning to have network connectivity between four buildings. Answer the question (i) to
(iv) after going through the building positions in the campus & other details which are
given below:

Main
Admin Building

Academic
Finance

The distances between various buildings of university are given as:-


Building 1 Building 2 Distance(in mtrs.)

Main Admin 50

Main Finance 100


Main Academic 70
Admin Finance 50
Finance Academic 70
Admin Academic 60

Page No. 14
Number of computers:-
Building No. of Computers
Main 150
Admin 75
Finance 50
Academic 60
As a network expert, you are required to give best possible solutions for the given 1
queries of the university administration:-
(a) Suggest cable layout for the connections between the various buildings, 1
(b) Suggest the most suitable building to house the server of the network of the
university, 1
(c) Suggest the placement of following devices with justification:
1. Switch/Hub 1
2. Repeater
(d) Suggest the technology out of the following for setting-up very fast Internet
connectivity among buildings of the university
1. Optical Fibre
2. Coaxial cable
3. Ethernet Cable

********

Page No. 15
Class XII
Computer Science (083)
Sample Question Paper 2018-19

Time allowed: 3 Hours Max. Marks: 70

General Instructions:

(a) All questions are compulsory.


(b) Programming Language with C++
(c) In Question 2(b, d) ,3 and 4 has internal choices.

Q. No. Part Question Description Marks


1 (a) Write the type of C++ Operators (Arithmetic, Logical, and Relational (2)
Operators) from thefollowing:
(i) !(ii) !=(iii) &&(iv) %

(b) Observe the following program very carefully and write the name of those (1)
header file(s), which are essentially needed to compile and execute
thefollowing program successfully:
void main()
{
char text[20], newText[20];
gets(text);
strcpy(newText,text);
for(int i=0;i<strlen(text);i++)
if(text[i] = =’A’)
text[i] = text[i]+2;
puts(text);
}

(c) Rewrite the following C++ code after removing any/all Syntactical Error(s) (2)
with each correction underlined.

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

#define float PI 3.14


void main( )
{
float R=4.5,H=1.5;
A=2*PI*R*H + 2*PIpow(R,2);
cout<<‘Area=’<<A<<endl;
}

1
(d) Find and write the output of the following C++ program code: (3)
Note: Assume all required header files are already being included in
the program.
void main( )
{
int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
int *Ptr = Ar , I ;
cout<<++*Ptr++ << '@' ;
I = Ar[3] - Ar[2] ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ;
for( ; I >=0 ; I -=2)
cout<<Ar[I] << '@' ;
}

(e) Find and write the output of the following C++ program code: (2)
typedef char STRING[80];
void MIXNOW(STRING S)
{
int Size=strlen(S);
for(int I=0;I<Size;I+=2)
{
char WS=S[I];
S[I]=S[I+1];
S[I+1]=WS;
}
for (I=1;I<Size;I+=2)
if (S[I]>=’M’ && S[I]<=’U’)
S[I]=’@’;
}
void main()
{
STRING Word=”CBSEEXAM2019”;
MIXNOW(Word);
cout<<Word<<endl;
}

(f) Observe the following program and find out, which output(s) out of (i) to (2)
(iv) willbe expected from the program? What will be the minimum and the
maximum value assigned to the variable Alter?

Note: Assume all required header files are already being included in the
program.
void main( )
{
randomize();
int Ar[]={10,7}, N;

2
int Alter=random(2) + 10 ;
for (int C=0;C<2;C++)
{
N=random(2) ;
cout<<Ar[N] +Alter<<”#”;
}
}
(i) 21#20# (ii) 20#18#
(iii) 20#17# (iv) 21#17#

2 (a) What is a copy constructor? Illustrate with a suitable C++ example. (2)

(b) Write the output of the following C++ code. Also, write the name of feature (2)
of Object Oriented Programming used in the following program jointly
illustrated by the Function 1 to Function 4.
void My_fun ( ) // Function 1
{
for (int I=1 ; I<=50 ; I++) cout<< "-" ;
cout<<end1 ;
}
void My_fun (int N) // Function 2
{
for (int I=1 ; I<=N ; I++) cout<<"*" ;
cout<<end1 ;
}
void My_fun (int A, int B) // Function 3
{
for (int I=1. ;I<=B ;I++) cout <<A*I ;
cout<<end1 ;
}
void My_fun (char T, int N) // Function 4
{
for (int I=1 ; I<=N ; I++) cout<<T ;
cout<<end1;
}
void main ( )
{
int X=7, Y=4, Z=3;
char C='#' ;
My_fun (C,Y) ;
My_fun (X,Z) ;
}

OR

(b) Write any four differences between Constructor and Destructor function
with respect to object oriented programming.

3
(c) Define a class Ele_Bill in C++ with the following descriptions: (4)
Private members:
Cname of type character array
Pnumber of type long
No_of_units of type integer
Amount of type float.
Calc_Amount( ) This member function should calculate the
amount as No_of_units*Cost .
Amount can be calculated according to the following conditions:
No_of_units Cost
First 50 units Free
Next 100 units 0.80 @ unit
Next 200 units 1.00 @ unit
Remaining units 1.20 @ unit
Public members:
* A function Accept( ) which allows user to enter Cname,
Pnumber, No_of_units and invoke function Calc_Amount().
* A function Display( ) to display the values of all the data members
on the screen.

(d) Answer the questions (i) to (iv) based on the following: (4)
class Faculty
{
int FCode;
protected:
char FName[20];
public:
Faculty();
void Enter();
void Show();
};
class Programme
{
int PID;
protected:
char Title[30];
public:
Programme();
void Commence();
void View();
};
class Schedule: public Programme, Faculty
{
int DD,MM,YYYY;
public:

4
Schedule();
void Start();
void View();
};
void main()
{
Schedule S; //Statement 1
___________ //Statement 2
}

(i) Write the names of all the member functions, which are directly accessible
by the object S of class Schedule as declared in main() function.

(ii) Write the names of all the members, which are directly accessible by the
memberfunction Start( ) of class Schedule.

(iii) Write Statement 2 to call function View( ) of class Programme from the
object S of class Schedule.

(iv) What will be the order of execution of the constructors, when the object S
of class Schedule is declared inside main()?

OR

(d) Consider the following class State :


class State
{
protected :
int tp;
public :
State( ) { tp=0;}
void inctp( ) { tp++;};
int gettp(); { return tp; }
};

Write a code in C++ to publically derive another class ‘District’


with the following additional members derived in the public
visibility mode.

Data Members :
Dname string
Distance float
Population long int

Member functions :
DINPUT( ) : To enter Dname, Distance and population
DOUTPUT( ) : To display the data members on the screen.

5
3 (a) Write a user-defined function AddEnd4(int A[][4],int R,int C) in C++ to (2)
find and display the sum of all the values, which are ending with 4 (i.e., unit
place is 4).
For example if the content of array is:
24 16 14
19 5 4
The output should be
42

OR

(a) Write a user defined function in C++ to find the sum of both left and right
diagonal elements from a two dimensional array.

(b) Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ (3)


to find and display the extra element in Array A. Array A contains all the
elements of array B but one more element extra. (Restriction: array
elements are not in order)

Example If the elements of Array A is 14, 21, 5, 19, 8, 4, 23, 11


and the elements of Array B is 23, 8, 19, 4, 14, 11, 5
Then output will be 21

OR
(b)
Write a user defined function Reverse(int A[],int n) which accepts an
integer array and its size as arguments(parameters) and reverse the array.
Example : if the array is 10,20,30,40,50 then reversed array is
50,40,30,20,10

(c) An array S[10] [30] is stored in the memory along the column with each of (3)
its element occupying 2 bytes. Find out the memory location of S[5][10], if
element S[2][15] is stored at the location 8200.

OR

(c) An array A[30][10] is stored in the memory with each element requiring 4
bytes of storage ,if the base address of A is 4500 ,Find out memory
locations of A[12][8], if the content is stored along the row.

(d) Write the definition of a member function Ins_Player() for a class (4)
CQUEUE in C++, to add a Player in a statically allocated circular queue of
PLAYERs considering the following code
is already written as a part of the program:
struct Player
{
long Pid;
char Pname[20];

6
};
const int size=10;
class CQUEUE
{
Player Ar[size];
int Front, Rear;
public:
CQUEUE( )
{
Front = -1;
Rear = -1;
}
void Ins_Player(); // To add player in a static circular queue
void Del_Player(); // To remove player from a static circular queue
void Show_Player(); // To display static circular queue
};

OR

(d) Write a function in C++ to delete a node containing Books information


,from a dynamically allocated stack of Books implemented with the help of
the following structure:
struct Book
{
int BNo;
char BName[20];
Book *Next;
};

(e) Convert the following Infix expression to its equivalent Postfix expression, (2)
showing the stack contents for each step of conversion.
A/B+C*(D-E)

OR

Evaluate the following Postfix expression :


4,10,5,+,*,15,3,/,-

4 (a) Write a function RevText() to read a text file “ Input.txt “ and Print only (2)
word starting with ‘I’ in reverse order .
Example: If value in text file is: INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY

OR

(a) Write a function in C++ to count the number of lowercase alphabets present
in a text file “BOOK..txt".

7
(b) Write a function in C++ to search and display details, whose destination is (3)
“Cochin” from binary file “Bus.Dat”. Assuming the binary file is
containing the objects of the following class:
class BUS
{ int Bno; // Bus Number
char From[20]; // Bus Starting Point
char To[20]; // Bus Destination
public:
char * StartFrom ( ); { return From; }
char * EndTo( ); { return To; }
void input() { cin>>Bno>>; gets(From); get(To); }
void show( ) { cout<<Bno<< “:”<<From << “:” <<To<<endl; }
};

OR

(b) Write a function in C++ to add more new objects at the bottom of a binary
file "STUDENT.dat", assuming the binary file is containing the objects of
the following class :
class STU
{
int Rno;
char Sname[20];
public: void Enter()
{
cin>>Rno;gets(Sname);
}
void show()
{
count << Rno<<sname<<endl;
}
};

(c) Find the output of the following C++ code considering that the binary file (1)
PRODUCT.DAT exists on the hard disk with a list of data of 500 products.
class PRODUCT
{
int PCode;char PName[20];
public:
void Entry();void Disp();
};
void main()
{
fstream In;
In.open("PRODUCT.DAT",ios::binary|ios::in);
PRODUCT P;
In.seekg(0,ios::end);
cout<<"Total Count: "<<In.tellg()/sizeof(P)<<endl;

8
In.seekg(70*sizeof(P));
In.read((char*)&P, sizeof(P));
In.read((char*)&P, sizeof(P));
cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
In.close();
}

OR

(c) Which file stream is required for seekg() ?

5 (a) Observe the following table and answer the parts(i) and(ii) accordingly (2)
Table:Product

Pno Name Qty PurchaseDate


101 Pen 102 12-12-2011
102 Pencil 201 21-02-2013
103 Eraser 90 09-08-2010
109 Sharpener 90 31-08-2012
113 Clips 900 12-12-2011

(i) Write the names of most appropriate columns, which can be considered as
candidate keys.

(ii) What is the degree and cardinality of the above table?

(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (4+2)
(viii), which are based on the tables.
TRAINER
TID TNAME CITY HIREDATE SALARY
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARG 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000

COURSE
CID CNAME FEES STARTDATE TID
C201 AGDCA 12000 2018-07-02 101
C202 ADCA 15000 2018-07-15 103
C203 DCA 10000 2018-10-01 102
C204 DDTP 9000 2018-09-15 104
C205 DHN 20000 2018-08-01 101
C206 O LEVEL 18000 2018-07-25 105

9
(i) Display the Trainer Name, City & Salary in descending order of their
Hiredate.

(ii) To display the TNAME and CITY of Trainer who joined the Institute in the
month of December 2001.

(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables


TRAINER and COURSE of all those courses whose FEES is less than or
equal to 10000.

(iv) To display number of Trainers from each city.

(v) SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT


IN(‘DELHI’, ‘MUMBAI’);

(vi) SELECT DISTINCT TID FROM COURSE;

(vii) SELECT TID, COUNT(*), MIN(FEES) FROM COURSE GROUP BY


TID HAVING COUNT(*)>1;

(viii) SELECT COUNT(*), SUM(FEES) FROM COURSE WHERE


STARTDATE< ‘2018-09-15’;

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

(b) Draw the Logic Circuit of the following Boolean Expression: (2)
((U + V’).(U + W)). (V + W’)

(c) Derive a Canonical SOP expression for a Boolean function F(X,Y,Z) (1)
represented by the following truth table:

X Y Z F(X,Y,Z)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

(d) Reduce the following Boolean Expression to its simplest form using K- (3)
Map:

F(X,Y,Z,W)= Σ (0,1,2,3,4,5,8,10,11,14)

10
7 (a) Arun opened his e-mail and found that his inbox was full of hundreds of (2)
unwanted mails. It took him around two hours to delete these unwanted
mails and find the relevant ones in his inbox. What may be the cause of his
receiving so many unsolicited mails? What can Arun do to prevent this
happening in future?

(b) Assume that 50 employees are working in an organization. Each employee (1)
has been allotted a separate workstation to work. In this way, all computers
are connected through the server and all these workstations are distributed
over two floors. In each floor, all the computers are connected to a switch.
Identify the type of network?

(c) Your friend wishes to install a wireless network in his office. Explain him (1)
the difference between guided and unguided media.

(d) Write the expanded names for the following abbreviated terms used in (2)
Networking and Communications:
(i) CDMA (ii) HTTP (iii) XML (iv) URL

(4)
(e) Multipurpose Public School, Bangluru is Setting up the network
between its Different Wings of school campus. There are 4
wings
namedasSENIOR(S),JUNIOR(J),ADMIN(A)andHOSTEL(H).

Multipurpose Public School, Bangluru

SENIOR JUNIOR

ADMIN HOSTEL

11
Distancebetweenvariouswingsaregivenbelow:
WingAtoWingS 100m

WingAtoWingJ 200m

WingAtoWingH 400m

WingStoWingJ 300m

WingStoWingH 100m

WingJtoWingH 450m

Number of Computers installed at various wings are as follows:

Wings NumberofComputers

WingA 20

WingS 150

WingJ 50

WingH 25

(i) Suggest the best wired medium and draw the cable layout to efficiently
connect various wings of Multipurpose PublicSchool, Bangluru.

(ii) Namethe most suitablewing wherethe Servershouldbe


installed.Justifyyour answer.

(iii) Suggest a device/software and its placement that would provide


data security for the entire network of the School.

(iv) Suggest a device and the protocol that shall be needed to provide wireless
Internet access to all smartphone/laptop users in the campus of
Multipurpose Public School, Bangluru.

12
COMPUTER SCIENCE – NEW (083)
SAMPLE QUESTION PAPER (2019-20)
CLASS- XII

Max. Marks: 70 Time: 3 hrs

General Instructions:

● All questions are compulsory.


● Question paper is divided into 4 sections A, B, C and D.
 Section A : Unit-1
 Section B : Unit-2
 Section C: Unit-3
 Section D: Unit-4

SECTION-A
(a) Which of the following is valid arithmetic operator in Python:
Q1. 1
(i) // (ii) ? (iii) < (iv) and

Write the type of tokens from the following:


(b) 1
(i) if (ii) roll_no
Name the Python Library modules which need to be imported to invoke the
(c) 1
following functions:
(i) sin() (ii) randint ()
Rewrite the following code in python after removing all syntax error(s).
(d) 2
Underline each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)
(e) Find and write the output of the following python code: 2
def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'bb'
print(m)
fun('school2@com')
(f) Find and write the output of the following python code: 3

1
def Change(P ,Q=30):
P=P+Q
Q=P-Q
print( P,"#",Q)
return (P)
R=150
S=100
R=Change(R,S)
print(R,"#",S)
S=Change(S)

What possible outputs(s) are expected to be displayed on screen at the time of


(g) 2
execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)

(i) 10#40#70# (ii) 30#40#50#


(iii) 50#60#70# (iv) 40#50#70#
Q2. (a) What do you understand by the term Iteration? 1
(b) Which is the correct form of declaration of dictionary? 1
(i) Day={1:’monday’,2:’tuesday’,3:’wednesday’}
(ii) Day=(1;’monday’,2;’tuesday’,3;’wednesday’)
(iii) Day=[1:’monday’,2:’tuesday’,3:’wednesday’]
(iv) Day={1’monday’,2’tuesday’,3’wednesday’]
Identify the valid declaration of L:
(c) 1
L = [1, 23, ‘hi’, 6].
(i) list (ii) dictionary (iii) array (iv) tuple

(d) Find and write the output of the following python code: 1

x = "abcdef"
i = "a"
while i in x:
print(i, end = " ")

2
(e) Find and write the output of the following python code: 1
a=10
def call():
global a
a=15
b=20
print(a)
call()

(f) What do you understand by local and global scope of variables? How can you 2
access a global variable inside the function, if function has a variable with same
name.
(g) A bar chart is drawn(using pyplot) to represent sales data of various models of 2
cars, for a month. Write appropriate statements in Python to provide labels
Month - June and Sale done to x and y axis respectively.
OR
Give the output from the given python code:

import matplotlib.pyplot as plt; plt.rcdefaults()


import numpy as np
import matplotlib.pyplot as plt

objects = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')


y_pos = np.arange(len(objects))
performance = [10,8,6,4,2,1]

plt.bar(y_pos, performance, align='center', alpha=0.5)


plt.xticks(y_pos, objects)
plt.ylabel('Usage')
plt.title('Programming language usage')

plt.show()

(h) Write a function in python to count the number of lines in a text file ‘STORY.TXT’ 2
which is starting with an alphabet ‘A’ .

OR

Write a method/function DISPLAYWORDS() in python to read lines from a text


file STORY.TXT, and display those words, which are less than 4 characters.

(i) Write a Recursive function in python BinarySearch(Arr,l,R,X) to search the given 3


element X to be searched from the List Arr having R elements,where l represents
lower bound and R represents the upper bound.
OR

3
Write a Recursive function recurfactorial(n) in python to calculate and return the
factorial of number n passed to the parameter.
(j) Write a function in Python, INSERTQ(Arr,data) and DELETEQ(Arr) for performing 4
insertion and deletion operations in a Queue. Arr is the list used for implementing
queue and data is the value to be inserted.
OR
Write a function in python, MakePush(Package) and MakePop(Package) to add a
new Package and delete a Package from a List of Package Description, considering
them to act as push and pop operations of the Stack data structure.
SECTION-B
Q.3 Questions 3 (a) to 3 (c) : Fill in the blanks
(a) ………………………..is an example of Public cloud. 1
(b) ……………………………. is a network of physical objects embedded with electronics, 1
software, sensors and network connectivity.
(c) ---------------------- is a device that forwards data packets along networks. 1
(d) ---------------------- describes the maximum data transfer rate of a network or 1
Internet connection.
(e) Give the full forms of the following 2
(i) HTTP
(ii) FTP
(v) VoIP
(vi) SSH
How many pair of wires are there in twisted pair cable(Ethernet)?What is the name
(f) 2
of port ,which is used to connect Ethernet cable to a computer or a labtop?

(g) Identify the type of cyber crime for the following situations: 3
(i) A person complains that Rs. 4.25 lacs have been fraudulently stolen
from his/her account online via some online transactions in two days
using NET BANKING.
(ii) A person complaints that his/her debit/credit card is safe with him still
some body has done shopping/ATM transaction on this card.
(iii) A person complaints that somebody has created a fake profile on
Facebook and defaming his/her character with abusive comments and
pictures.

Software Development Company has set up its new center at Raipur for its office
(h) 4
and web based activities. It has 4 blocks of buildings named Block A, Block B, Block
C, Block D.
Number of Computers

4
Block A 25

Block B 50

Block C 125

Block D 10

Shortest distances between various Blocks in meters:

Block A to Block B 60 m
Block B to Block C 40 m
Block C to Block A 30 m
Block D to Block C 50 m

(i) Suggest the most suitable place (i.e. block) to house the
server of this company with a suitable reason.
(ii) Suggest the type of network to connect all the blocks with
suitable reason .
(iii)The company is planning to link all the blocks through a secure and high
speed wired medium. Suggest a way to connect all the blocks.
(iv) Suggest the most suitable wired medium for efficiently connecting each
computer installed in every block out of the following network cables:
● Coaxial Cable
● Ethernet Cable
● Single Pair Telephone Cable.

SECTION-C
Q.4 (a) Which key word is used to sort the records of a table in descending order? 1
(b) Which clause is used to sort the records of a table? 1
(c) Which command is used to modify the records of the table? 1
(d) Which clause is used to remove the duplicating rows of the table? 1
(e) Differentiate between Primary key and Candidate key. 2
OR
Differentiate between Degree and Cardinality.
(f) Differentiate between Django GET and POST method. 2
Write a output for SQL queries (i) to (iii), which are based on the table: STUDENT
(g) 3

5
given below:
Table : STUDENT

(i) SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING


COUNT(*)>1;
(ii) SELECT MAX(DOB),MIN(DOB) FROM STUDENT;
(iii) SELECT NAME,GENDER FROM STUDENT WHERE CITY=”Delhi”;

Write SQL queries for (i) to (iv), which are based on the table: STUDENT given in
(h) 4
the question 4(g):
(i) To display the records from table student in alphabetical order as per
the name of the student.
(ii) To display Class, Dob and City whose marks is between 450 and 551.
(iii) To display Name, Class and total number of students who have
secured more than 450 marks, class wise
(iv) To increase marks of all students by 20 whose class is “XII”

SECTION-D
Q.5 (a) It is an internet service for sending written messages electronically from one 1
computer to another. Write the service name.
(b) As a citizen of india , What advise you should give to others for e-waste disposal? 1
(c) What can be done to reduce the risk of identity theft? Write any two ways. 2

6
(d) 2

Ravi received a mail form IRS department ( as shown above). On clicking “ Click-
Here” ,he was taken to a site designed to imitate an official-looking website, such
as IRS.gov. He uploaded some important information on it.

Identify and explain the cybercrime being discussed in the above scenario.
(e) 2
Differentiate between open source and open data.
(f) Enumerate any two disability issues while teaching and using computers 2

7
Class: XII Session: 2020-21
Computer Science (083)
Sample Question Paper (Theory)
Maximum Marks: 70 Time Allowed: 3 hours

General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2 sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question 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
internal option.
6. All programming questions are to be answered using Python Language only

Question Part-A Marks


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

1 Find the invalid identifier from the following 1


a) MyName b) True c) 2ndName d) My_Name

2 Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[2:5]) 1

3 Write the full form of CSV. 1

4 Identify the valid arithmetic operator in Python from the following. 1


a) ? b) < c) ** d) and

Page 1 of 11
5 Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is 1
incorrect?
a) print(T[1])
b) T[2] = -29
c) print(max(T))
d) print(len(T))

6 Write a statement in Python to declare a dictionary whose keys are 1, 2, 3 1


and values are Monday, Tuesday and Wednesday respectively.

7 A tuple is declared as 1
T = (2,5,6,9,8)
What will be the value of sum(T)?

8 Name the built-in mathematical function / method that is used to return an 1


absolute value of a number.

9 Name the protocol that is used to send emails. 1

10 Your friend Ranjana complaints that somebody has created a fake profile on 1
Facebook and defaming her character with abusive comments and pictures.
Identify the type of cybercrime for these situations.

11 In SQL, name the clause that is used to display the tuples in ascending order 1
of an attribute.

12 In SQL, what is the use of IS NULL operator? 1

13 Write any one aggregate function used in SQL. 1

14 Which of the following is a DDL command? 1


a) SELECT b) ALTER c) INSERT d) UPDATE

15 Name The transmission media best suitable for connecting to hilly areas. 1

16 Identify the valid declaration of L: 1


L = [‘Mon’, ‘23’, ‘hello’, ’60.5’]

Page 2 of 11
a. dictionary b. string c.tuple d. list
17 If the following code is executed, what will be the output of the following 1
code?

name="ComputerSciencewithPython"
print(name[3:10])

18 In SQL, write the query to display the list of tables stored in a database. 1

19 Write the expanded form of Wi-Fi. 1

20 Which of the following types of table constraints will prevent the entry of 1
duplicate rows?
a) Unique
b) Distinct
c) Primary Key
d) NULL

21 Rearrange the following terms in increasing order of data transfer rates. 1


Gbps, Mbps, Tbps, Kbps, bps
Section-II
Both the Case study based questions are compulsory. Attempt any 4
sub parts from each question. Each question carries 1 mark

22 A departmental store MyStore is considering to maintain their inventory


using SQL to store the data. As a database administer, Abhay has decided
that :
• Name of the database - mystore
• Name of the table - STORE
• The attributes of STORE are as follows:
ItemNo - numeric
ItemName – character of size 20
Scode - numeric
Quantity – numeric

Page 3 of 11
Table : STORE
ItemNo ItemName Scode Quantity
2005 Sharpener Classic 23 60
2003 Ball Pen 0.25 22 50
2002 Get Pen Premium 21 150
2006 Get Pen Classic 21 250
2001 Eraser Small 22 220
2004 Eraser Big 22 110
2009 Ball Pen 0.5 21 180
(a) Identify the attribute best suitable to be declared as a primary key, 1
(b) Write the degree and cardinality of the table STORE. 1

(c) Insert the following data into the attributes ItemNo, ItemName and 1
SCode respectively in the given table STORE.
ItemNo = 2010, ItemName = “Note Book” and Scode = 25
(d) Abhay want to remove the table STORE from the database MyStore. 1
Which command will he use from the following:
a) DELETE FROM store;
b) DROP TABLE store;
c) DROP DATABASE mystore;
d) DELETE store FROM mystore;

(e) Now Abhay wants to display the structure of the table STORE, i.e, 1
name of the attributes and their respective data types that he has
used in the table. Write the query to display the same.

23 Ranjan Kumar of class 12 is writing a program to create a CSV file “user.csv”


which will contain user name and password for some entries. He has written
the following code. As a programmer, help him to successfully execute the
given task.

import _____________ # Line 1

def addCsvFile(UserName,PassWord): # to write / add data into the


CSV file
f=open(' user.csv','________') # Line 2

Page 4 of 11
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()

#csv file reading code


def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv._________(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.______________ # Line 4

addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile() #Line 5

(a) Name the module he should import in Line 1. 1

(b) In which mode, Ranjan should open the file to add data into the file 1
(c) Fill in the blank in Line 3 to read the data from a csv file. 1
(d) Fill in the blank in Line 4 to close the file. 1
(e) Write the output he will obtain while executing Line 5. 1
Part – B

Section-I
24 Evaluate the following expressions: 2
a) 6 * 3 + 4**2 // 5 – 8
b) 10 > 5 and 7 > 12 or not 18 > 3

25 Differentiate between Viruses and Worms in context of networking and data 2


communication threats.
OR
Differentiate between Web server and web browser. Write any two popular
web browsers.
26 Expand the following terms: 2
a. SMTP b. XML c. LAN d. IPR

Page 5 of 11
27 Differentiate between actual parameter(s) and a formal parameter(s) with a 2
suitable example for each.
OR
Explain the use of global key word used in a function with the help of a
suitable example.

28 Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.

Value=30
for VAL in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val%5==0:
print (VAL+3)
else
print(VAL+10)

29 What possible outputs(s) are expected to be displayed on screen at the time 2


of execution of the program from the following code? Also specify the
maximum values that can be assigned to each of the variables Lower and
Upper.

import random
AR=[20,30,40,50,60,70];
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)

(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv)


40#50#70#

30 What do you understand by Candidate Keys in a table? Give a suitable 2


example of Candidate Keys from a table containing some meaningful data.

Page 6 of 11
31 Differentiate between fetchone() and fetchall() methods with suitable 2
examples for each.
32 Write the full forms of DDL and DML. Write any two commands of DML in 2
SQL.
33 Find and write the output of the following Python code: 2

def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)

Display('[email protected]')

Section- II

34 Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers 3


and n is a numeric value by which all elements of the list are shifted to left.
Sample Input Data of the list
Arr= [ 10,20,30,40,12,11], n=2
Output
Arr = [30,40,12,11,10,20]

35 Write a function in Python that counts the number of “Me” or “My” words 3
present in a text file “STORY.TXT”.
If the “STORY.TXT” contents are as follows:
My first book
was Me and

Page 7 of 11
My Family. It
gave me
chance to be
Known to the
world.

The output of the function should be:


Count of Me/My in file: 4

OR

Write a function AMCount() in Python, which should read each character


of a text file STORY.TXT, should count and display the occurance of
alphabets A and M (including small cases a and m too).
Example:
If the file content is as follows:
Updated information
As simplified by official websites.
The EUCount() function should display the output as:
A or a:4
M or m :2

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

Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
1 Jugal 34 Computer Sc 10/01/2017 12000 M
2 Sharmila 31 History 24/03/2008 20000 F
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
7 Shiv Om 44 Computer Sc 25/02/2017 21000 M
8 Shalakha 33 Mathematics 31/07/2018 20000 F

Page 8 of 11
Table : Posting
P_ID Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi

i. SELECT Department, count(*) FROM Teacher


GROUP BY Department;
ii. SELECT Max(Date_of_Join),Min(Date_of_Join)
FROM Teacher;
iii. SELECT Teacher.name,Teacher.Department,
Posting.Place FROM Teachr, Posting WHERE
Teacher.Department = Posting.Department AND
Posting.Place=”Delhi”;

37 Write a function in Python PUSH(Arr), where Arr is a list of numbers. From 3


this list push all numbers divisible by 5 into a stack implemented by using a
list. Display the stack if it has at least one element, otherwise display
appropriate error message.
OR
Write a function in Python POP(Arr), where Arr is a stack implemented by a
list of numbers. The function returns the value deleted from the stack.

Section-III
38 MyPace University is setting up its academic blocks at Naya Raipur 5
and is planning to set up a network. The University has 3 academic
blocks and one Human Resource Center as shown in the diagram
below:

Center to Center distances between various blocks/center is as follows:

Page 9 of 11
Law Block to business Block 40m
Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology
30m
Block
Business Block to HR Center 35m
Technology block to HR center 15m
Number of computers in each of the blocks/Center is as follows:
Law Block 15
Technology Block 40
HR center 115
Business Block 25

a) Suggest the most suitable place (i.e., Block/Center) to install


the server of this University with a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a
wired connectivity.
c) Which device will you suggest to be placed/installed in each
of these blocks/centers to efficiently connect all the
computers within these blocks/centers.
d) Suggest the placement of a Repeater in the network
with justification.
e) The university is planning to connect its admission office in
Delhi, which is more than 1250km from university. Which
type of network out of LAN, MAN, or WAN will be formed?
Justify your answer.

39 Write SQL commands for the following queries (i) to (v) based on the 5
relations Teacher and Posting given below:

Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
Computer
1 Jugal 34 10/01/2017 12000 M
Sc
2 Sharmila 31 History 24/03/2008 20000 F

Page 10 of 11
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
Computer
7 Shiv Om 44 25/02/2017 21000 M
Sc
8 Shalakha 33 Mathematics 31/07/2018 20000 F

Table : Posting
P_ID Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi

i. To show all information about the teacher of History


department.
ii. To list the names of female teachers who are in Mathematics
department.
iii. To list the names of all teachers with their date of joining in
ascending order.
iv. To display teacher’s name, salary, age for male teachers only.
v. To display name, bonus for each teacher where bonus is 10%
of salary.
40 5
A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
i. Write a user defined function CreateFile() to input data for a
record and add to Book.dat .
ii. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of
books by the given Author are stored in the binary file
“Book.dat”

OR
A binary file “STUDENT.DAT” has structure (admission_number, Name,
Percentage). Write a function countrec() in Python that would read contents
of the file “STUDENT.DAT” and display the details of those students whose
percentage is above 75. Also display number of students scoring above 75%

Page 11 of 11
Sample Question Paper
Class: XII Session: 2021-22
Computer Science (Code 083)
(Theory: Term-1)
Maximum Marks: 35 Time Allowed: 90 Minutes

General Instructions:

 The question paper is divided into 3 Sections - A, B and C.


 Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
 Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
 Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
 All questions carry equal marks.
Q.N. Section-A

This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.

1 Find the invalid identifier from the following


a. none
b. address
c. Name
d. pass
2 Consider a declaration L = (1, 'Python', '3.14').
Which of the following represents the data type of L?
a. list
b. tuple
c. dictionary
d. string
3 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90).
What will be the output of print (tup1 [3:7:2])?
a. (40,50,60,70,80)
b. (40,50,60,70)
c. [40,60]
d. (40,60)
4 Which of the following option is not correct?
a. if we try to read a text file that does not exist, an error occurs.
b. if we try to read a text file that does not exist, the file gets created.
c. if we try to write on a text file that does not exist, no error occurs.
d. if we try to write on a text file that does not exist, the file gets
Created.
5 Which of the following options can be used to read the first line of a text file Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()
6 Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which
of the following option can be used to read all the remaining lines?
a. myfile.read()
b. myfile.read(n)
c. myfile.readline()
d. myfile.readlines()
7 A text file student.txt is stored in the storage device. Identify the correct option out of the
following options to open the file in read mode.
i. myfile = open('student.txt','rb')
ii. myfile = open('student.txt','w')
iii. myfile = open('student.txt','r')
iv. myfile = open('student.txt')

a. only i
b. both i and iv
c. both iii and iv
d. both i and iii
8 The return type of the input() function is
a. string
b. integer
c. list
d. tuple
9 Which of the following operator cannot be used with string data type?
a. +
b. in
c. *
d. /
10 Consider a tuple tup1 = (10, 15, 25, and 30). Identify the statement that will result in an
error.
a. print(tup1[2])
b. tup1[2] = 20
c. print(min(tup1))
d. print(len(tup1))
11 Which of the following statement is incorrect in the context of binary files?
a. Information is stored in the same format in which the information is held in
memory.
b. No character translation takes place
c. Every line ends with a new line character
d. pickle module is used for reading and writing
12 What is the significance of the tell() method?
a. tells the path of file
b. tells the current position of the file pointer within the file
c. tells the end position within the file
d. checks the existence of a file at the desired location
13 Which of the following statement is true?
a. pickling creates an object from a sequence of bytes
b. pickling is used for object serialization
c. pickling is used for object deserialization
d. pickling is used to manage all types of files in Python

14 Syntax of seek function in Python is myfile.seek(offset, reference_point) where myfile is


the file object. What is the default value of reference_point?
a. 0
b. 1
c. 2
d. 3
15 Which of the following components are part of a function header in Python?
a. Function Name
b. Return Statement
c. Parameter List
d. Both a and c
16 Which of the following function header is correct?
a. def cal_si(p=100, r, t=2)
b. def cal_si(p=100, r=8, t)
c. def cal_si(p, r=8, t)
d. def cal_si(p, r=8, t=2)
17 Which of the following is the correct way to call a function?
a. my_func()
b. def my_func()
c. return my_func
d. call my_func()
18 Which of the following character acts as default delimiter in a csv file?
a. (colon) :
b. (hyphen) -
c. (comma) ,
d. (vertical line) |
19 Syntax for opening Student.csv file in write mode is
myfile = open("Student.csv","w",newline='').

What is the importance of newline=''?


a. A newline gets added to the file
b. Empty string gets appended to the first line.
c. Empty string gets appended to all lines.
d. EOL translation is suppressed
20 What is the correct expansion of CSV files?
a. Comma Separable Values
b. Comma Separated Values
c. Comma Split Values
d. Comma Separation Values
21 Which of the following is not a function / method of csv module in Python?
a. read()
b. reader()
c. writer()
d. writerow()
22 Which one of the following is the default extension of a Python file?
a. .exe
b. .p++
c. .py
d. .p
23 Which of the following symbol is used in Python for single line comment?
a. /
b. /*
c. //
d. #
24 Which of the following statement opens a binary file record.bin in write mode and writes
data from a list lst1 = [1,2,3,4] on the binary file?
a. with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)

b. with open('record.bin','wb') as myfile:


pickle.dump(myfile,lst1)

c. with open('record.bin','wb+') as myfile:


pickle.dump(myfile,lst1)

d. with open('record.bin','ab') as myfile:


pickle.dump(myfile,lst1)
25 Which of these about a dictionary is false?
a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c) Dictionaries aren’t ordered
d) Dictionaries are mutable
Section-B

This section consists of 24 Questions (26 to 49). Attempt any 20 questions.


26 What is the output of following code:
T=(100)
print(T*2)
a. Syntax error
b. (200,)
c. 200
d. (100,100)
27 Suppose content of 'Myfile.txt' is:

Twinkle twinkle little star


How I wonder what you are
Up above the world so high
Like a diamond in the sky

What will be the output of the following code?


myfile = open("Myfile.txt")
data = myfile.readlines()
print(len(data))
myfile.close()
a. 3
b. 4
c. 5
d. 6
28 Identify the output of the following Python statements.
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][2]
print(y)
a. 12.0
b. 13.0
c. 14.0
d. 15.0
29 Identify the output of the following Python statements.
x = 2
while x < 9:
print(x, end='')
x = x + 1
a. 12345678

b. 123456789
c. 2345678

d. 23456789

30 Identify the output of the following Python statements.


b = 1
for a in range(1, 10, 2):
b += a + 2
print(b)
a. 31
b. 33
c. 36
d. 39
31 Identify the output of the following Python statements.
lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
a. 2
b. 3
c. 4
d. 20
32 Raghav is trying to write a tuple tup1 = (1,2,3,4,5) on a binary file test.bin. Consider the
following code written by him.
import pickle
tup1 = (1,2,3,4,5)
myfile = open("test.bin",'wb')
pickle._______ #Statement 1
myfile.close()
Identify the missing code in Statement 1.
a. dump(myfile,tup1)
b. dump(tup1, myfile)
c. write(tup1,myfile)
d. load(myfile,tup1)
33 A binary file employee.dat has following data
Empno empname Salary
101 Anuj 50000
102 Arijita 40000
103 Hanika 30000
104 Firoz 60000
105 Vijaylakshmi 40000

def display(eno):
f=open("employee.dat","rb")
totSum=0
try:
while True:
R=pickle.load(f)
if R[0]==eno:
__________ #Line1
totSum=totSum+R[2]
except:
f.close()
print(totSum)

When the above mentioned function, display (103) is executed, the output displayed is
190000.
Write appropriate jump statement from the following to obtain the above output.
a. jump
b. break
c. continue
d. return
34 What will be the output of the following Python code?
def add (num1, num2):
sum = num1 + num2
sum = add(20,30)
print(sum)
a. 50
b. 0
c. Null
d. None
35 Evaluate the following expression and identify the correct answer.
16 - (4 + 2) * 5 + 2**3 * 4
a. 54
b. 46
c. 18
d. 32
36 What will be the output of the following code?
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())
a. 100 200
b. 150 300
c. 250 75
d. 250 300
37 What will be the output of the following code?
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
a. 50#50
b. 50#5
c. 50#30
d. 5#50#
38 What will be the output of the following code?
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
a. Delhi#Mumbai#Chennai#Kolkata#
b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi#
d. Mumbai# Mumbai #Chennai # Mumbai
39 What is the output of the following code snippet?
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="#")
a) 5#8#15#4#
b) 5#8#5#4#
c) 5#8#15#14#
d) 5#18#15#4#

40 Suppose content of 'Myfile.txt' is


Humpty Dumpty sat on a wall
Humpty Dumpty had a great fall
All the king's horses and all the king's men
Couldn't put Humpty together again
What will be the output of the following code?
myfile = open("Myfile.txt")
record = myfile.read().split()
print(len(record))
myfile.close()
a. 24
b. 25
c. 26
d. 27
41 Find the output of the following code:
Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)

a. pYTHOn##@
b. pYTHOnN#@
c. pYTHOn#@
d. pYTHOnN@#
42 Suppose content of 'Myfile.txt' is
Honesty is the best policy.
What will be the output of the following code?
myfile = open("Myfile.txt")
x = myfile.read()
print(len(x))
myfile.close()
a. 5
b. 25
c. 26
d. 27
43 Suppose content of 'Myfile.txt' is
Culture is the widening of the mind and of the spirit.
What will be the output of the following code?
myfile = open("Myfile.txt")
x = myfile.read()
y = x.count('the')
print(y)
myfile.close()
a. 2
b. 3
c. 4
d. 5
44 What will be the output of the following code?
x = 3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
a. 3 3 3
b. 3 4 5
c. 3 3 5
d. 3 5 5
45 Suppose content of 'Myfile.txt' is
Ek Bharat Shreshtha Bharat

What will be the output of the following code?


myfile = open("Myfile.txt")
vlist = list("aeiouAEIOU")
vc=0
x = myfile.read()
for y in x:
if(y in vlist):
vc+=1
print(vc)
myfile.close()
a. 6
b. 7
c. 8
d. 9
46 Suppose content of 'Myfile.txt' is

Twinkle twinkle little star


How I wonder what you are
Up above the world so high
Like a diamond in the sky
Twinkle twinkle little star

What will be the output of the following code?


myfile = open("Myfile.txt")
line_count = 0
data = myfile.readlines()
for line in data:
if line[0] == 'T':
line_count += 1
print(line_count)
myfile.close()
a. 2
b. 3
c. 4
d. 5
47 Consider the following directory structure.

Suppose root directory (School) and present working directory are the same. What will
be the absolute path of the file Syllabus.jpg?
a. School/syllabus.jpg
b. School/Academics/syllabus.jpg
c. School/Academics/../syllabus.jpg
d. School/Examination/syllabus.jpg

48 Assume the content of text file, 'student.txt' is:

Arjun Kumar
Ismail Khan
Joseph B
Hanika Kiran

What will be the data type of data_rec?


myfile = open("Myfile.txt")
data_rec = myfile.readlines()
myfile.close()
a. string
b. list
c. tuple
d. dictionary

49 What will be the output of the following code?


tup1 = (1,2,[1,2],3)
tup1[2][1]=3.14
print(tup1)
a. (1,2,[3.14,2],3)
b. (1,2,[1,3.14],3)
c. (1,2,[1,2],3.14)
d. Error Message
Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.

Rohit, a student of class 12, is learning CSV File Module in Python. During examination,
he has been assigned an incomplete python code (shown below) to create a CSV File
'Student.csv' (content shown below). Help him in completing the code which creates the
desired CSV File.

CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A

Incomplete Code
import _____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = [ ]
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [ _____ ] #Statement-4
data.append(_____) #Statement-5
stuwriter. _____ (data) #Statement-6
fh.close()
50 Identify the suitable code for blank space in the line marked as Statement-1.
a) csv file
b) CSV
c) csv
d) cvs
51 Identify the missing code for blank space in line marked as Statement-2.
a) "Student.csv","wb"
b) "Student.csv","w"
c) "Student.csv","r"
d) "Student.cvs","r"
52 Choose the function name (with argument) that should be used in the blank space of line
marked as Statement-3.
a) reader(fh)
b) reader(MyFile)
c) writer(fh)
d) writer(MyFile)
53 Identify the suitable code for blank space in line marked as Statement-4.
a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
b) ROLL_NO, NAME, CLASS, SECTION
c) 'roll_no','name','Class','section'
d) roll_no,name,Class,section

54 Identify the suitable code for blank space in the line marked as Statement-5.
a) data
b) record
c) rec
d) insert

55 Choose the function name that should be used in the blank space of line marked as
Statement-6 to create the desired CSV File?
a) dump()
b) load()
c) writerows()
d) writerow()
Sample Question Paper
COMPUTER SCIENCE (Code: 083)
Maximum Marks: 35 Time: 2 hours

General Instructions

 The question paper is divided into 3 sections – A, B and C


 Section A, consists of 7 questions (1-7). Each question carries 2 marks.
 Section B, consists of 3 questions (8-10). Each question carries 3 marks.
 Section C, consists of 3 questions (11-13). Each question carries 4 marks.
 Internal choices have been given for question numbers 7, 8 and 12.

Section -A
Each question carries 2 marks
Q. Part Question Marks
No No.
1. Give any two characteristics of stacks. (2)

2. (i) Expand the following: (1)


SMTP , XML

(ii) Out of the following, which is the fastest wired and wireless medium (1)
of transmission?

Infrared, coaxial cable, optical fibre,


microwave, Ethernet cable

3. Differentiate between char(n) and varchar(n) data types with respect (2)
to databases.

4. A resultset is extracted from the database using the cursor object (2)
(that has been already created) by giving the following statement.

Mydata=cursor.fetchone()

(a) How many records will be returned by fetchone()


method?
(b) What will be the datatype of Mydata object after the
given command is executed?

[1]
5. Write the output of the queries (a) to (d) based on the table, (2)
Furniture given below:

Table: FURNITURE
FID NAME DATEOFPURCHASE COST DISCOUNT
B001 Double 03-Jan-2018 45000 10
Bed
T010 Dining 10-Mar-2020 51000 5
Table
B004 Single 19-Jul-2021 22000 0
Bed
C003 Long 30-Dec-2016 12000 3
Back
Chair
T006 Console 17-Nov-2019 15000 12
Table
B006 Bunk 01-Jan-2021 28000 14
Bed

(a) SELECT SUM(DISCOUNT)


FROM FURNITURE
WHERE COST>15000;

(b) SELECT MAX(DATEOFPURCHASE)


FROM FURNITURE;

(c) SELECT * FROM FURNITURE


WHERE DISCOUNT>5 AND FID LIKE "T%";

(d) SELECT DATEOFPURCHASE FROM FURNITURE


WHERE NAME IN ("Dining Table", "Console
Table");

6. (i) Which command is used to view the list of tables in a database? (1)

(ii) Give one point of difference between an equi-join and a natural join. (1)

7. Consider the table, MOVIEDETAILS given below: (2)

Table: MOVIEDETAILS
MOVIEID TITLE LANGUAGE RATING PLATFORM
M001 Minari Korean 5 Netflix
M004 MGR Magan Tamil 4 Hotstar
[2]
M010 Kaagaz Hindi 3 Zee5
M011 Harry English 4 Prime
Potter Video
and the
Chamber
of
Secrets
M015 Uri Hindi 5 Zee5
M020 Avengers: English 4 Hotstar
Endgame

(a) Identify the degree and cardinality of the table.


(b) Which field should be made the primary key? Justify your
answer.

OR

(a) Identify the candidate key(s) from the table MOVIEDETAILS.


(b) Consider the table SCHEDULE given below:

Table: SCHEDULE
SLOTID MOVIEID TIMESLOT
S001 M010 10 AM to 12 PM
S002 M020 2 PM to 5 PM
S003 M010 6 PM to 8 PM
S004 M011 9 PM to 11 PM

Which field will be considered as the foreign key if the tables


MOVIEDETAILS and SCHEDULE are related in a database?

SECTION – B
Each question carries 3 marks

8. Julie has created a dictionary containing names and marks as key (3)
value pairs of 6 students. Write a program, with separate user
defined functions to perform the following operations:

● Push the keys (name of the student) of the dictionary into a


stack, where the corresponding value (marks) is greater than
75.
● Pop and display the content of the stack.
For example:
If the sample content of the dictionary is as follows:

[3]
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90,
"TOM":82}

The output from the program should be:


TOM ANU BOB OM

OR

Alam has a list containing 10 integers. You need to help him create
a program with separate user defined functions to perform the
following operations based on this list.
● Traverse the content of the list and push the even numbers
into a stack.
● Pop and display the content of the stack.

For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]

Sample Output of the code should be:


38 22 98 56 34 12

9. (i) A table, ITEM has been created in a database with the following (1)
fields:
ITEMCODE, ITEMNAME, QTY, PRICE

Give the SQL command to add a new field, DISCOUNT (of type
Integer) to the ITEM table.
(ii) Categorize following commands into DDL and DML commands? (2)

INSERT INTO, DROP TABLE, ALTER TABLE,


UPDATE...SET

10. Charu has to create a database named MYEARTH in MYSQL. (3)


She now needs to create a table named CITY in the database to store
the records of various cities across the globe. The table CITY has the
following structure:

Table: CITY
FIELD NAME DATA TYPE REMARKS

CITYCODE CHAR(5) Primary


Key
CITYNAME CHAR(30)
SIZE INTEGER

[4]
AVGTEMP INTEGER
POLLUTIONRATE INTEGER
POPULATION INTEGER

Help her to complete the task by suggesting appropriate SQL


commands.
Section C
Each question carries 4 marks

11. Write queries (a) to (d) based on the tables EMPLOYEE and (4)
DEPARTMENT given below:

Table: EMPLOYEE
EMPID NAME DOB DEPTID DESIG SALARY
120 Alisha 23- D001 Manager 75000
Jan-
1978
123 Nitin 10- D002 AO 59000
Oct-
1977
129 Navjot 12- D003 Supervisor 40000
Jul-
1971
130 Jimmy 30- D004 Sales Rep
Dec-
1980
131 Faiz 06- D001 Dep 65000
Apr- Manager
1984

Table: DEPARTMENT

DEPTID DEPTNAME FLOORNO


D001 Personal 4
D002 Admin 10
D003 Production 1
D004 Sales 3

(a) To display the average salary of all employees, department wise.

(b) To display name and respective department name of each


employee whose salary is more than 50000.
[5]
(c) To display the names of employees whose salary is not known, in
alphabetical order.

(d) To display DEPTID from the table EMPLOYEE without repetition.

12. (i) Give two advantages and two disadvantages of star topology (2)

OR

Define the following terms:


www , web hosting

(ii) How is packet switching different from circuit switching? (2)

13. BeHappy Corporation has set up its new centre at Noida, Uttar (4)
Pradesh for its office and web-based activities. It has 4 blocks of
buildings.

BeHappy Corporation
Block B
Block A

Block D
Block C

Distance between the various blocks is as follows:


A to B 40 m
B to C 120m
C to D 100m
A to D 170m
B to D 150m
A to C 70m

Numbers of computers in each block


Block A - 25
[6]
Block B - 50
Block C - 125
Block D - 10

(a) Suggest and draw the cable layout to efficiently connect


various blocks of buildings within the Noida centre for
connecting the digital devices.

(b) Suggest the placement of the following device with


justification
i. Repeater
ii. Hub/Switch

(c) Which kind of network (PAN/LAN/WAN) will be formed if the


Noida office is connected to its head office in Mumbai?

(d) Which fast and very effective wireless transmission medium


should preferably be used to connect the head office at
Mumbai with the centre at Noida?

[7]
Class: XII Session: 2022-23
Computer Science (083)
Sample Question Paper (Theory)
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is
given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False 1
“Variable declaration is implicit in Python.”

2. Which of the following is an invalid datatype in Python? 1


(a) Set (b) None (c)Integer (d)Real

3. Given the following dictionaries 1

dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}

Which statement will merge the contents of both dictionaries?


a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)

4. Consider the given expression: 1


not True and False or True
Which of the following will be correct output if the given expression is
evaluated?

(a) True
(b) False
(c) NONE
(d) NULL

5. Select the correct output of the code: 1


a = "Year 2022 at All the best"
1
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)

(a) Year . 0. at All the best


(b) Year 0. at All the best
(c) Year . 022. at All the best
(d) Year . 0. at all the best

6. Which of the following mode in file opening statement results or 1


generates an error if the file does not exist?

(a) a+ (b) r+ (c) w+ (d) None of the above

7. Fill in the blank: 1

______ command is used to remove primary key from the table in SQL.

(a) update (b)remove (c) alter (d)drop

8. Which of the following commands will delete the table from MYSQL 1
database?
(a) DELETE TABLE
(b) DROP TABLE
(c) REMOVE TABLE
(d) ALTER TABLE

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


executing the following code?

S="Welcome to class XII" # Statement 1


print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5

10. Fill in the blank: 1

_________ is a non-key attribute, whose values are derived from the


primary key of some other table.
(a) Primary Key
(b) Foreign Key
(c) Candidate Key

2
(d) Alternate Key

11. The correct syntax of seek() is: 1


(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
12. Fill in the blank: 1
The SELECT statement when combined with __________ clause,
returns records without repetition.

(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL

13. Fill in the blank: 1


______is a communication methodology designed to deliver both voice
and multimedia communications over Internet protocol.

(a) VoIP (b) SMTP (c) PPP (d)HTTP

14. What will the following expression be evaluated to in Python? 1


print(15.0 / 4 + (8 + 3.0))

(a) 14.75 (b)14.0 (c) 15 (d) 15.5

15. Which function is used to display the total number of records from 1
table in a database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)

16. To establish a connection between Python and SQL database, 1


connect() is used. Which of the following arguments may not
necessarily be given while calling connect() ?

(a) host
(b) database
(c) user
(d) password

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A

3
(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

17. Assertion (A):- If the arguments in function call statement match the 1
number and order of arguments as defined in the function definition,
such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).

18. Assertion (A): CSV (Comma Separated Values) is a file format for data 1
storage which looks like a text file.
Reason (R): The information is organized with one record on each line
and each field is separated by comma.

SECTION B
19. Rao has written a code to input a number and check whether it is 2
prime or not. His code is having errors. Rewrite the correct code and
underline the corrections made.

def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)

20. Write two points of difference between Circuit Switching and Packet 2
Switching.

OR

Write two points of difference between XML and HTML.

21. (a) Given is a Python string declaration: 1


myexam="@@CBSE Examination 2022@@"

Write the output of: print(myexam[::-2])

1
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

22. Explain the use of ‘Foreign Key’ in a Relational Database Management 2


System. Give example to support your answer.

4
23. (a) Write the full forms of the following: 2
(i) SMTP (ii) PPP

(b) What is the use of TELNET?

24. Predict the output of the Python code given below: 2

def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1

NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

OR

Predict the output of the Python code given below:

tuple1 = (11, 22, 33, 44, 55 ,66)


list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

25. Differentiate between count() and count(*) functions in SQL with 2


appropriate example.

OR

Categorize the following commands as DDL or DML:


INSERT, UPDATE, ALTER, DROP

SECTION C

26. (a) Consider the following tables – Bank_Account and Branch: 1+2

Table: Bank_Account
ACode Name Type
A01 Amrita Savings
A02 Parthodas Current
A03 Miraben Current
5
Table: Branch

ACode City
A01 Delhi
A02 Mumbai
A01 Nagpur

What will be the output of the following statement?

SELECT * FROM Bank_Account NATURAL JOIN Branch;

(b) Write the output of the queries (i) to (iv) based on the table,
TECH_COURSE given below:

Table: TECH_COURSE
CID CNAME FEES STARTDATE TID
C201 Animation and VFX 12000 2022-07-02 101
C202 CADD 15000 2021-11-15 NULL
C203 DCA 10000 2020-10-01 102
C204 DDTP 9000 2021-09-15 104
C205 Mobile Application 18000 2022-11-01 101
Development
C206 Digital marketing 16000 2022-07-25 103

(i) SELECT DISTINCT TID FROM TECH_COURSE;


(ii) SELECT TID, COUNT(*), MIN(FEES) FROM
TECH_COURSE GROUP BY TID HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM TECH_COURSE WHERE
FEES>15000 ORDER BY CNAME;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE
FEES BETWEEN 15000 AND 17000;
27. Write a method COUNTLINES() in Python to read lines from text file 3
‘TESTFILE.TXT’ and display the lines which are not starting with any
vowel.

Example:

If the file content is as follows:

An apple a day keeps the doctor away.


We all pray for everyone’s safety.
A marked difference will come in our country.

The COUNTLINES() function should display the output as:

6
The number of lines not starting with any vowel - 1

OR

Write a function ETCount() in Python, which should read each


character of a text file “TESTFILE.TXT” and then count and display
the count of occurrence of alphabets E and T individually (including
small cases e and t too).

Example:

If the file content is as follows:

Today is a pleasant day.


It might rain today.
It is mentioned on weather sites

The ETCount() function should display the output as:


E or e: 6
T or t : 9

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:

Table : Teacher

T_ID Name Age Department Date_of_join Salary Gender


1 Arunan 34 Computer Sc 2019-01-10 12000 M
2 Saman 31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4 Samira 35 History 2018-07-01 40000 F
5 Raman 42 Mathematics 2021-09-05 25000 M
6 Shyam 50 History 2019-06-27 30000 M
7 Shiv 44 Computer Sc 2019-02-25 21000 M
8 Shalakha 33 Mathematics 2018-07-31 20000 F

Table : Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur

(i) SELECT Department, avg(salary) FROM Teacher


GROUP BY Department;
(ii) SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM
Teacher;
(iii) SELECT Name, Salary, T.Department, Place FROM
Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
(iv) SELECT Name, Place FROM Teacher T, Placement P

7
WHERE Gender =’F’ AND T.Department=P.Department;
(b) Write the command to view all tables in a database.

29. Write a function INDEX_LIST(L), where L is the list of elements passed 3


as argument to the function. The function returns another list named
‘indexList’ that stores the indices of all Non-Zero Elements of L.

For example:

If L contains [12,4,0,11,0,56]

The indexList will have - [0,1,3,5]

30. A list contains following record of a customer: 3


[Customer_name, Phone_number, City]

Write the following user defined functions to perform given operations


on the stack named ‘status’:
(i) Push_element() - To Push an object containing name and
Phone number of customers who live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and
display them. Also, display “Stack Empty” when there are no
elements in the stack.
For example:
If the lists of customer details are:

[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]

The stack should contain


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty

OR

Write a function in Python, Push(SItem) where , SItem is a dictionary


containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who
have price greater than 75. Also display the count of elements pushed
into the stack.
For example:
If the dictionary contains the following data:
8
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

The stack should contain


Notebook
Pen

The output should be:


The count of elements in the stack is 2

SECTION D
31. MakeInIndia Corporation, an Uttarakhand based IT training company,
is planning to set up training centres in various cities in next 2 years.
Their first campus is coming up in Kashipur district. At Kashipur
campus, they are planning to have 3 different blocks for App
development, Web designing and Movie editing. Each block has
number of computers, which are required to be connected in a
network for communication, data and resource sharing. As a network
consultant of this company, you have to suggest the best network
related solutions for them for issues/problems raised in question nos.
(i) to (v), keeping in mind the distances between various
blocks/locations and other given parameters.
KASHIPUR
APP CAMPUS
DEVELOPM MOVIE
ENT EDITING
MUSSOORIE
CAMPUS
WEB
DESIGNING

Distance between various blocks/locations:

Block Distance
App development to Web designing 28 m
App development to Movie editing 55 m
Web designing to Movie editing 32 m
Kashipur Campus to Mussoorie Campus 232 km

Number of computers
Block Number of Computers
App development 75
Web designing 50
Movie editing 80

(i) Suggest the most appropriate block/location to house the


SERVER in the Kashipur campus (out of the 3 blocks) to get the 1
best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in the Kashipur
1
Campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout (Block
1
9
to Block) to economically connect various blocks within the
Kashipur Campus.
(iv) Suggest the placement of the following devices with appropriate 1
reasons:
a. Switch / Hub
b. Repeater
1
(v) Suggest a protocol that shall be needed to provide Video
Conferencing solution between Kashipur Campus and Mussoorie
Campus.
32. (a) Write the output of the code given below: 2+3

p=5
def sum(q,r=2):
global p
p=r+q**2
print(p, end= '#')

a=10
b=5
sum(a,b)
sum(r=5,q=1)

(b) The code given below inserts the following record in the table
Student:

RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and


MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named school.
 The details (RollNo, Name, Clas and Marks) are to
be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the
table Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",

10
password="tiger", database="school")
mycursor=_________________ #Statement 1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
clas=int(input("Enter class :: "))
marks=int(input("Enter Marks :: "))
querry="insert into student
values({},'{}',{},{})".format(rno,name,clas,marks)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")

OR

(a) Predict the output of the code given below:

s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

(b) The code given below reads the following record from the table
named student and displays only those records who have
marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and


MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named school.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those
students whose marks are greater than 75.
Statement 3- to read the complete result of the query (records whose
11
marks are greater than 75) into the object named data, from the
table student in the database.

import mysql.connector as mysql


def sql_data():

con1=mysql.connect(host="localhost",user="root",
password="tiger", database="school")
mycursor=_______________ #Statement 1
print("Students with marks greater than 75 are :
")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

33. What is the advantage of using a csv file for permanent storage? 5
Write a Program in Python that defines and calls the following user
defined functions:

(i) ADD() – To accept and add data of an employee to a CSV file


‘record.csv’. Each record consists of a list with field elements
as empid, name and mobile to store employee id, employee
name and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV
file named ‘record.csv’.
OR

Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user
defined functions:

(i) add() – To accept and add data of an employee to a CSV


file ‘furdata.csv’. Each record consists of a list with field
elements as fid, fname and fprice to store furniture
id, furniture name and furniture price respectively.
(ii) search()- To display the records of the furniture whose
price is more than 10000.

SECTION E
34. Navdeep creates a table RESULT with a set of records to maintain 1+1+2
the marks secured by students in Sem 1, Sem2, Sem3 and their
division. After creation of the table, he has entered data of 7
students in the table.

ROLL_NO SNAME SEM1 SEM2 SEM3 DIVISION

101 KARAN 366 410 402 I

102 NAMAN 300 350 325 I

12
103 ISHA 400 410 415 I

104 RENU 350 357 415 I

105 ARPIT 100 75 178 IV

106 SABINA 100 205 217 II

107 NEELAM 470 450 471 I

Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be considered


as Primary key.
(ii) If two columns are added and 2 rows are deleted from the table
result, what will be the new degree and cardinality of the
above table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-
475, Div – I.
b. Increase the SEM2 marks of the students by 3% whose
name begins with ‘N’.
OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype as
varchar with 50 characters

35. Aman is a Python programmer. He has written a code and created a


binary file record.dat with employeeid, ename and salary. The file
contains 10 records.
He now has to update a record based on the employee id entered by
the user and update the salary. The updated record is then to be
written in the file temp.dat. The records which are not to be
updated also have to be written to the file temp.dat. If the
employee id is not found, an appropriate message should to be
displayed.
As a Python expert, help him to complete the following code based on
the requirement given above:

import _______ #Statement 1


def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their
13
salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary
:: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has
been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
1
(i) Which module should be imported in the program? (Statement
1
1)
(ii) Write the correct statement required to open a temporary file
named temp.dat. (Statement 2) 2
(iii) Which statement should Aman fill in Statement 3 to read the
data from the binary file, record.dat and in Statement 4 to
write the updated data in the file, temp.dat?

14
Sample Question Paper
Class: XII Session: 2023-24
Computer Science (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 3 questions (31 to 33). Each question carries 5 Marks.
 Section E, consists of 2 questions (34 to 35). Each question carries 4 Marks.
 All programming questions are to be answered using Python Language only.

Ques. Question Marks


No.
SECTION A
1 State True or False: 1
“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”
2 In a table in MYSQL database, an attribute A of datatype varchar(20) 1
has the value “Keshav”. The attribute B of datatype char(20) has
value “Meenakshi”. How many characters are occupied by attribute A
and attribute B?
a. 20,6 b. 6,20
c. 9,6 d. 6,9

3 What will be the output of the following statement: 1


print(3-2**2**3+99/11)
a. 244 b. 244.0
c. -244.0 d. Error

4 Select the correct output of the code: 1

[1]
Options:
a. PYTHON-IS-Fun
b. PYTHON-is-Fun
c. Python-is-fun
d. PYTHON-Is -Fun
5 In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and 1
another table, Beta has degree 3 and cardinality 5, what will be the
degree and cardinality of the Cartesian product of Alpha and Beta?
a. 5,3 b. 8,15
c. 3,5 d. 15,8

6 Riya wants to transfer pictures from her mobile phone to her laptop. She 1
uses Bluetooth Technology to connect two devices. Which type of
network will be formed in this case?
a. PAN b. LAN
c. MAN d. WAN

7 Which of the following will delete key-value pair for key = “Red” from a 1
dictionary D1?
a. delete D1("Red")
b. del D1["Red"]
c. del.D1["Red"]
d. D1.del["Red"]
8 Consider the statements given below and then choose the correct output 1
from the given options:
pride="#G20 Presidency"
print(pride[-2:2:-2])

[2]
Options
a. ndsr
b. ceieP0
c. ceieP
d. yndsr

9 Which of the following statement(s) would give an error during execution 1


of the following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
Options:
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4

10 What possible outputs(s) will be obtained when the following code is 1


executed?

Options:
a.
RED*
WHITE*
BLACK*

[3]
RED*
b.
YELLOW*
WHITE*
BLACK*
RED*
c.
WHITE* WHITE*
YELLOW* YELLOW*
BLACK* BLACK*
RED* RED*
d.
YELLOW*
WHITE*WHITE*
BLACK* BLACK* BLACK*
RED* RED* RED* RED* RED*

11 Fill in the blank: 1


The modem at the sender’s computer end acts as a ____________.
a. Model
b. Modulator
c. Demodulator
d. Convertor

12 Consider the code given below: 1

[4]
Which of the following statements should be given in the blank for
#Missing Statement, if the output produced is 110?
Options:
a. global a
b. global b=100
c. global b
d. global a=100

13 State whether the following statement is True or False: 1


An exception may be raised even if the program is syntactically correct.
14 Which of the following statements is FALSE about keys in a relational 1
database?
a. Any candidate key is eligible to become a primary key.
b. A primary key uniquely identifies the tuples in a relation.
c. A candidate key that is not a primary key is a foreign key.
d. A foreign key is an attribute whose value is derived from the
primary key of another relation.

15 Fill in the blank: 1


In case of _____________ switching, before a communication starts, a
dedicated path is identified between the sender and the receiver.
16 Which of the following functions changes the position of file pointer and 1
returns its new position?
a. flush()
b. tell()
c. seek()
d. offset()

Q17 and 18 are ASSERTION AND REASONING 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
[5]
17 Assertion(A): List is an immutable data type 1
Reasoning(R): When an attempt is made to update the value of an
immutable variable, the old variable is destroyed and a new variable is
created by the same name in memory.
18 Assertion(A): Python standard library consists of number of modules. 1
Reasoning(R): A function in a module is used to simplify the code and
avoids repetition.

SECTION B
19 (i) Expand the following terms: 1+1=2
POP3 , URL
(ii) Give one difference between XML and HTML.

20 The code given below accepts a number as an argument and returns the 2
reverse number. Observe the following code carefully and rewrite it after
removing all syntax and logical errors. Underline all the corrections made.

21 Write a function countNow(PLACES) in Python, that takes the 2


dictionary, PLACES as an argument and displays the names (in
uppercase)of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New
York",5:"Doha"}
The output should be:

[6]
LONDON
NEW YORK
OR
Write a function, lenWords(STRING), that takes a string as an
argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the
tuple will have (4, 3, 2, 4, 4, 3)
22 Predict the output of the following code: 2

23 Write the Python statement for each of the following tasks using BUILT- 1+1=2
IN functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full
stop / period or not.
24 Ms. Shalini has just created a table named “Employee” containing 2
columns Ename, Department and Salary.
After creating the table, she realized that she has forgotten to add a
primary key column in the table. Help her in writing an SQL command to
add a primary key column EmpId of integer type to the table
Employee.
Thereafter, write the command to insert the following record in the table:

[7]
EmpId- 999
Ename- Shweta
Department: Production
Salary: 26900
25 Predict the output of the following code: 2

SECTION C
26 Predict the output of the Python code given below: 3

27 Consider the table CLUB given below and write the output of the SQL 1*3=3
queries that follow.

[8]
CID CNAME AGE GENDER SPORTS PAY DOAPP
5246 AMRITA 35 FEMALE CHESS 900 2006-
03-27
4687 SHYAM 37 MALE CRICKET 1300 2004-
04-15
1245 MEENA 23 FEMALE VOLLEYBALL 1000 2007-
06-18
1622 AMRIT 28 MALE KARATE 1000 2007-
09-05
1256 AMINA 36 FEMALE CHESS 1100 2003-
08-15
1720 MANJU 33 FEMALE KARATE 1250 2004-
04-10
2321 VIRAT 35 MALE CRICKET 1050 2005-
04-30

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;


(ii) SELECT CNAME, SPORTS FROM CLUB WHERE
DOAPP<"2006-04-30" AND CNAME LIKE "%NA";
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE
GENDER = "MALE" AND PAY BETWEEN 1000 AND
1200;
28 Write a function in Python to read a text file, Alpha.txt and displays 3
those lines which begin with the word ‘You’.
OR
Write a function, vowelCount() in Python that counts and displays the
number of vowels in the text file named Poem.txt.
29 Consider the table Personal given below: 1*3=3
Table: Personal

[9]
P_ID Name Desig Salary Allowance

P01 Rohit Manager 89000 4800


P02 Kashish Clerk NULL 1600
P03 Mahesh Superviser 48000 NULL

P04 Salil Clerk 31000 1900


P05 Ravina Superviser NULL 2100

Based on the given table, write SQL queries for the following:
(i) Increase the salary by 5% of personals whose allowance is
known.
(ii) Display Name and Total Salary (sum of Salary and Allowance)
of all personals. The column heading ‘Total Salary’ should also
be displayed.
(iii) Delete the record of Supervisors who have salary greater than
25000
30 A list, NList contains following record as list elements: 3
[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the
following user defined functions in Python to perform the specified
operations on the stack named travel.
(i) Push_element(NList): It takes the nested list as an
argument and pushes a list object containing name of the city
and country, which are not in India and distance is less than
3500 km from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays
them. Also, the function should display “Stack Empty” when
there are no elements in the stack.
[10]
For example: If the nested list contains the following data:
NList=[["New York", "U.S.A.", 11734],
["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194],
["London", "England", 6693],
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty

SECTION D
31 Meticulous EduServe is an educational organization. It is planning to setup 1*5=5
its India campus at Chennai with its head office at Delhi. The Chennai
campus has 4 main buildings – ADMIN, ENGINEERING, BUSINESS and
MEDIA

Block to Block distances (in Mtrs.)


From To Distance
ADMIN ENGINEERING 55 m

[11]
ADMIN BUSINESS 90 m
ADMIN MEDIA 50 m
ENGINEERING BUSINESS 55 m
ENGINEERING MEDIA 50 m
BUSINESS MEDIA 45 m
DELHI HEAD CHENNAI 2175 km
OFFICE CAMPUS

Number of computers in each of the blocks/Center is as follows:


ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI HEAD 20

a) Suggest and draw the cable layout to efficiently connect various blocks
of buildings within the CHENNAI campus for connecting the digital
devices.
b) Which network device will be used to connect computers in each block
to form a local area network?
c) Which block, in Chennai Campus should be made the server? Justify
your answer.
d) Which fast and very effective wireless transmission medium
should preferably be used to connect the head office at DELHI with the
campus in CHENNAI?
e) Suggest a device/software to be installed in the CHENNAI
Campus to take care of data security.
32 (i) Differentiate between r+ and w+ file modes in Python. 2+3=5
(ii) Consider a file, SPORT.DAT, containing records of the following
structure:

[12]
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file
SPORT.DAT and copies the records with Sport name as “Basket
Ball” to the file named BASKET.DAT. The function should return the
total number of records copied to the file BASKET.DAT.
OR
(Option for part (ii) only)
A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype
as parameter and displays all the records from the binary file
CINEMA.DAT, that have the value of Movie Type as mtype.
33 (i) Define the term Domain with respect to RDBMS. Give one 1+4=5
example to support your answer.
(ii) Kabir wants to write a program in Python to insert the following
record in the table named Student in MYSQL database,
SCHOOL:
 rno(Roll number )- integer
 name(Name) - string
 DOB (Date of birth) – Date
 Fee – float
Note the following to establish connectivity between Python and
MySQL:
 Username - root
 Password - tiger

[13]
 Host - localhost
The values of fields rno, name, DOB and fee has to be accepted
from the user. Help Kabir to write the program in Python.

SECTION E
34 Consider the tables PRODUCT and BRAND given below: 1*4=4
Table: PRODUCT
PCode PName UPrice Rating BID
P01 Shampoo 120 6 M03
P02 Toothpaste 54 8 M02
P03 Soap 25 7 M03
P04 Toothpaste 65 4 M04
P05 Soap 38 5 M05
P06 Shampoo 245 6 M05

Table: BRAND
BID BName
M02 Dant Kanti
M03 Medimix
M04 Pepsodent
M05 Dove

Write SQL queries for the following:


(i) Display product name and brand name from the tables
PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending
order of rating.

[14]
35 Vedansh is a Python programmer working in a school. For the Annual 4
Sports Event, he has created a csv file named Result.csv, to store the
results of students in different sports events. The structure of
Result.csv is :
[St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost'
or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the
following user defined functions:
Accept() – to accept a record from the user and add it to the file
Result.csv. The column headings should also be added on top of the
csv file.
wonCount() – to count the number of students who have won any
event.
As a Python expert, help him complete the task.

[15]

You might also like