Computer ScienceSQP
Computer ScienceSQP
COMPUTER SCIENCE
(Subject Code 083)
SAMPLE PAPER 2014 - 15
Section A (C++)
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
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
}
#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-
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
};
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];
};
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:
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)
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
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’
Instance attributes:
d) What are the different ways of overriding function call in derived class of
python ? Illustrate with example. [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]
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]
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]
Section C
Q5. a. Define degree and cardinality. Based upon given table write degree and
cardinality. [2]
PATIENTS
b. Write SQL commands for the queries (i) to (iv) and output for (v) & (viii) based
COMPANY
CID NAME CITY PRODUCTNAME
CUSTOMER
CUSTID NAME PRICE QTY CID
(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”;
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]
SENIOR
JUNIOR
ADMIN
HOSTEL
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]<<”$$”;
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”
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
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.
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()
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
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.
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)
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
13
Distance between various buildings is given as follows:
MrktDept to FunDept 80 m
FunDept to SalesDept 50 m
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.
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
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:
(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:
(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
Margin Remarks
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
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.
iv. To display watch name and their quantity sold in first quarter.
(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
(f) Rehaana Medicos Center has set up its new center in Dubai. It has
four buildings as shown in the diagram given below:
Number of Computers
Accounts 25
Store 15
Packaging Unit 60
(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):
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.
(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
(d) Answer the questions (i) and (ii) based on the following: 4
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:
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
Main Admin 50
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
General Instructions:
(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.
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
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.
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
(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
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
5 (a) Observe the following table and answer the parts(i) and(ii) accordingly (2)
Table:Product
(i) Write the names of most appropriate columns, which can be considered as
candidate keys.
(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.
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).
SENIOR JUNIOR
ADMIN HOSTEL
11
Distancebetweenvariouswingsaregivenbelow:
WingAtoWingS 100m
WingAtoWingJ 200m
WingAtoWingH 400m
WingStoWingJ 300m
WingStoWingH 100m
WingJtoWingH 450m
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.
(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
General Instructions:
SECTION-A
(a) Which of the following is valid arithmetic operator in Python:
Q1. 1
(i) // (ii) ? (iii) < (iv) and
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)
(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:
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
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
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
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
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))
7 A tuple is declared as 1
T = (2,5,6,9,8)
What will be the value of sum(T)?
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.
15 Name The transmission media best suitable for connecting to hilly areas. 1
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
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
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.
Page 4 of 11
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile() #Line 5
(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
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)
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=”#“)
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
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.
OR
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
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:
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
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
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:
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.
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
b. 123456789
c. 2345678
d. 23456789
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#
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
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
Arjun Kumar
Ismail Khan
Joseph B
Hanika Kiran
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
Section -A
Each question carries 2 marks
Q. Part Question Marks
No No.
1. Give any two characteristics of stacks. (2)
(ii) Out of the following, which is the fastest wired and wireless medium (1)
of transmission?
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()
[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
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)
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
OR
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
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:
[3]
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90,
"TOM":82}
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]
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)
Table: CITY
FIELD NAME DATA TYPE REMARKS
[4]
AVGTEMP INTEGER
POLLUTIONRATE INTEGER
POPULATION INTEGER
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
12. (i) Give two advantages and two disadvantages of star topology (2)
OR
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
[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.”
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
(a) True
(b) False
(c) NONE
(d) NULL
______ command is used to remove primary key from the table in SQL.
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
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
2
(d) Alternate Key
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
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(*)
(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
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())
4
23. (a) Write the full forms of the following: 2
(i) SMTP (ii) PPP
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
OR
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
(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
Example:
6
The number of lines not starting with any vowel - 1
OR
Example:
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
Table : Teacher
Table : Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur
7
WHERE Gender =’F’ AND T.Department=P.Department;
(b) Write the command to view all tables in a database.
For example:
If L contains [12,4,0,11,0,56]
[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
OR
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
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
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
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
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
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:
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:
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.
12
103 ISHA 400 410 415 I
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.
[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
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*
[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
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.
[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
[9]
P_ID Name Desig Salary Allowance
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
[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
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
[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]