You are on page 1of 15

KVS JAMMU REGION

Class: XII Session: 2020-21


Computer Science (083)

Sample Paper -5 (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

Part-A marks
Q.No.
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
shape-hight b. _area c. #circle d. triangle123
Ans.
shape-hight : invalid identifier
#circle : invalid identifier

2 Does a list need to be homogeneous? 1


Ans. No. Different types of object can be mixed together in a list.
3 In ___________ files each line terminates with EOL or ‘\n’ or carriage return, or ‘\r\n’. 1
Ans. Text File
4 ------ and ------- are known as advanced Python operators like the identity operator. 1
Ans. is , is not
5 What will be the output of the following code snippet? 1
init_tuple_a = '1', '2'
init_tuple_b = ('3', '4')
print (init_tuple_a + init_tuple_b)

a. (1, 2, 3, 4) b. (‘1’, ‘2’, ‘3’, ‘4’) c. [‘1’, ‘2’, ‘3’, ‘4’] d. None
Answer. b
6 Write a python command to create list of keys from a dictionary. 1
dict = {‘a’: ’A’, ‘b’: ’B’, ‘c’: ’C’, ‘d’: ’D’}
Ans. dict.keys()
7 What will be the output of the following code snippet? 1
init_tuple = ((1, 2),) * 7
print(len(init_tuple[3:8]))
Ans. C. 4
8 Name the built-in mathematical function / method that is used to return the largest integer 1
less than or equal to of a number.
Ans. Floor
9 Name the protocol that is used transmitting files between computers on the internet over 1
TCP/IP connections
Ans. FTP
10 Stealing one’s information such as username and password is 1
Ans. Identity theft
11 In SQL, name the clause is used to retrieve data from 2 or more tables 1
Ans. Join
12 In SQL, what is subquery? 1
Ans. A subquery is a query within another query. The outer query is called as main query,
and inner query is called subquery
13 Write any one scaler function used in SQL 1
Ans. Scalar function – UCASE(), NOW()
14 Which of the following is not a DML command? 1
SELECT b. DELETE c. INSERT d. UPDATE
Ans. SELECT
15 Name the network device to regenerate the signal over the same network before the signal 1
becomes too weak or corrupted so as to extend the length to which the signal can be
transmitted over the same network
Ans. Repeater
16 Name the function of list that removes an item from the list. 1
Ans. Remove()
17 Which of the following is the output of the below Python code? 1
str='Tech Beamers'
print (str[4:9])
a. Beame b. Beam c. Beamer d. Beamers
Ans. b. Beam
18 Write an SQL query to fetch unique values of DEPARTMENT from Worker table. 1
Ans. Select distinct DEPARTMENT from Worker
19 Write the expanded form of Wi-Fi. 1
Ans. User Datagram Protocol
20 Which clause is used in combination with the GROUP BY clause? 1
a. UNIQUE b. CHECK c. HAVING d. DEFAULT
21 Which is not a network topology? 1
BUS b. STAR c. DIMOND d. RING
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 Consider a database LOANS with the following table:

AccN Cust_Name Loan_Amount Instalments Int_Rate Start_Date Inerest


o
1 R.K. Gupta 300000 36 12.00 19-07-2009 1200
2 S.P. Sharma 500000 48 10.00 22-03 -2008 1800
3 K.P. Jain 300000 36 NULL 08-03-2007 1600
4 M.P. Yadav 800000 60 10.00 06-12-2008 2250
5 S.P. Sinha 200000 36 12.50 03-01-2010 4500
6 P. Sharma 700000 60 12.50 05-06-2008 3500
7 K.S. Dhall 500000 48 NULL 05-03-2008 3800
Answer the following questions.
Display the sum of all Loan Amounts whose Interest rate is greater than 10.
Display the Maximum Interest from Loans table. 1
Display the count of all loan holders whose name ends with 'Sharma'. 1
Disp lay the count of all loan holders whose Interest is Null. 1
Display the Interest-wise details of Loan Account Holders. 1
1
Ans.
Mysql> select sum(Loan_Amount) from LOANS where Interest >10;
Mysql> select max(lnterest) from LOANS;
Mysql> select count( * ) from LOANS where Cu st_Name like '%Sharma';
Mysql> select count(*) from LOANS where Interest is NULL;
Mysql> select * from LOANS group by Interest;

23 Pushpa writing a program to create a CSV file “item.csv” which will contain item name,
Price and quantity of some entries. He has written the following code. As a programmer,
help him to successfully execute the given task.

import _____________ # Line 1

def addInCsv(item,price,qty): # to write / add data into the CSV file


f=open(' item.csv','________') # Line 2
csvFileWriter = csv.writer(f)
csvFileWriter.writerow([item,price,qty])
f.close()

#csv file reading code


def readFromCsv(): # to read data from CSV file
with open(' item.csv','r') as csvFile:
newFileReader = csv._________( csvFile) # Line 3
for row in newFileReader:
print (row[0],row[1],row[2])
csvFile.______________ # Line 4
addInCsv('Note Book', 45, 100)
addInCsv('Text Book', 60, 150)
addInCsv('Ball Pen', 10, 100)
addInCsv('Pencil', 5, 200)

readFromCsv() #Line 5

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


(b) In which mode, Pushpa 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

Ans.
(a) Line 1 : csv
(b) Line 2 : a
(c) Line 3 : reader
(d) Line 4 : close()

(e) Line 5 :
'Note Book', 45, 100
'Text Book', 60, 150
'Ball Pen', 10, 100
'Pencil', 2, 200
Part – B
Section - I
24 if a=7 and b=4 then what will be the output. 2
a. print('a <= b is',a<=b)
b. print('a and b is',a and b)

ans. a <= b is False


b. a and b is 4
25 What Is Spyware and its characteristics. 2
Ans.
Spyware is a type of malware installed on computers that collects information about users
without their knowledge. The presence of spyware is typically hidden from the user and can
be difficult to detect.

Or

What is difference between IP address and MAC address


Ans. Both MAC Address and IP Address are used to uniquely identify a machine on the
internet. MAC Address ensure that physical address of the computer is unique and  IP
Address is a logical address of the computer and is used to uniquely locate computer
connected via a network.
26 What are the full form of following term? 2
PHP b. ITA c. SIP d. GSP
Ans.
a. PHP-Hypertext Pre-processor
b. ITA-Information Technology Act
c. SIP- Session Initiation Protocol
d. GSP-Global system for mobile communication
27 What do you mean by keyword argument in python? Describe with example. 2

Ans. When you assign a value to the parameter (such as param=value) and pass to the
function (like fn(param=value)), then it turns into a keyword argument.

Or
What is scope of a variable in python and write basic scopes of variables in Python.

Ans. The program part(s) in which a particular piece of code or data value can be accessed is
known as variable scope. In python broadly scopes can either be global scope or local scope.

28 Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined. (2)

DEF execmain():
x = input("Enter a number:")
if (abs(x)= x):
print("You entered a positive number")
else:
x=*-1
print ("Number made positive:" x)
execmain()

Ans.
def execmain():
x = input("Enter a number:")
if (abs(x)== x):
print("You entered a positive number")
else:
x*=-1
print ("Number made positive:" ,x)
execmain()

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

import random
X= random.random()
Y= random.randint(0,4)
print(int(X),":",Y+int(X))
(i) 0 : 0 (ii) 1 : 6 (iii) 2 : 4 (iv) 0 : 3

Ans. (i) and (iv) are the possible outputs. Minimum value that can be assigned is Y = 0.
Maximum value that can be assigned is Y = 3.
30 Define the following terms: Field, Record, Table. 2
Ans.
Field: A field is the smallest unit of a table which is also known as a column. Columns are
called attributes in a table. For example, Employee Name, Employee ID, etc.
Record: A record is a collection of values/fields of a specific entity. For example, record of
an employee
that consists of Employee name, Salary, etc.
Table: A table is called a relation. It is a collection of records of a specific type of data. For
example,
employee table, salary table, etc., that can consist of the records of employees and records of
salary
respectively.
31 What are the basic steps to connect with MySQL using table Members? 2
Ans. import MySQLdb
conn = MySQLdb . connect (host= ' host ', user= ' user ', passwd= ' passwd ', db= ' db ')
cursor = conn. cursor ()
cursor. execute (' SELECT COUNT (MemberID) as count FROM Members WHERE id= 1')
row = cursor . fetchone ()
conn . close ()
print (row )
32 What do you understand by Data Redundancy and Data Consistency? 2
Ans.
Data Redundancy:
Data redundancy is a condition created within a database or data storage technology in which
the same piece of data is held in two separate places.A DBMS eliminates data redundancy
(duplication of data) by integrating the files so that multiple copies of the same data are not
stored.
Data Consistency: A DBMS provides data consistency to a larger extent as the changes made
at one place are reflected at all other places or to all the users.
33 Write the output of the following code when executed 2

def makenew(mystr):
newstr = ""
count = 0
for i in mystr:
if count%2 != 0:
newstr = newstr + str(count)
else:
if i.islower():
newstr = newstr + i.upper()
else:
newstr = newstr + i
count += 1
newstr = newstr + mystr[:1]
print("The new string is:", newstr)
makenew("sTUdeNT")

Ans. The new string is: S1U3E5Ts

Section- II

34 Write the definition of a function Reverse(X) in Python, to display the elements in reverse 3
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 = [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

Ans.
def Reverse(X):
for i in range(len(X)-1, -1, -1):
print(X[i]*2, end=" ")

35 Write a user defined function in python that displays the number of lines starting with 'H' in 3
the file para.txt.
Ans.
def count_H():
f = open (“para.txt” , “r” )
lines =0
L=f.readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)

OR
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-"This is my website. I have displayed my


preference in the CHOICE section “. -the countmy() function should display the output as:
“my occurs 2 times".
Ans.
def countmy():
f=open (“DATA.txt”, ”r”)
count=0
x= f.read()
word =x.split()
for i in word:
if (I == “my”):
count =count + 1
print (“my occurs”, count, “times”)

36 Consider the tables EMPLOYEE and SALGRADE given below and answer (a) and (C) parts 3
of this question.
To display the details of all EMPLOYEEs in descending order of DOJ.
To display NAME and DESIG of those EMPLOYEES whose SALGRADE is either S02 or
S03.
To display the content of the entire EMPLOYEES table, whose DOJ is in between '09-Feb-
2006' and '08-Aug-2009'.
Ans.
select * from EMPLOYEE order by DOJ desc;
select NAME, DESIG from EMPLOYEE where SGRADE=’S02’ OR SGRADE=’S03’;
select* from EMPLOYEE where DOJ between '09-Feb-2006' and '08-Aug-2009';
37 Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Book and 3
delete a Book from a list of Book titles, considering them to act as push and pop operations
of the Stack data structure.
Ans.
Def PushOn(Book):
a=input(“enter book title :”)
Book.append(a)
Def Pop(Book):
If (Book==[]):
print(“Stack empty”)
Else:
print(“Deleted element :”)
Book.pop()
OR
Write InsertQ(Customer) and DeleteQ(Customer) methods/functions in Python to add a new
Customer and delete a Customer from a list of Customer names, considering them to act as
insert and delete operations of the Queue
Ans.
def InsertQ(queue):
a=input(“Enter customer name :”)
queue.append(a)
def DeleteQ(queue):
if (queue==[]):
print (“Queue is empty…..”)
else:
print(“Deleted element is”, queue[0])
del queue[0]
Section-III
38 Rovenza Communications International (RCI) is an online corporate training provider 5
company for IT related courses. The company is setting up their new compus in Kolkata.
You as a network expert have to study the physical locations of various blocks and the
number of computers to be installed. In the planning phase, provide the best possible
answers for the queries (a) to (e) raised by them.

a. Suggest the most appropriate block, where RCI should plan to install the server.
b. Suggest the most appropriate block to block cable layout to connect all three blocks for
efficient communication.
c. Which type of network out of the following is formed by connecting the computers of
these three blocks?
LAN
MAN
WAN
d. Which wireless channel out of the following should be opted by RCI to connect to
students from all over the world?
Infrared
Microwave
Satellite
e. Suggest the placement of a switch/Hub in the network with justification.

Ans.
a. Faculty Recording Block.
b. Star topology
c. LAN
d. Satellite connection
e. Every block has more then one computer so switch/hub is required in every block.
39 Consider the following tables Sender and Recipient. Write SQL commands for the 5
statements (a) to (c) and give the outputs for SQL queries (d) to (e).
Sender
SenderID SenderName SenderAddress Sendercity
ND01 R Jain 2, ABC Appls New Delhi
MU02 H Sinha 12 Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122-K,SDA New Delhi
Recipients
RecID SenderID RecName RecAddress recCity
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A-Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 P K Swamy B5, C S Terminals Mumbai
ND48 ND50 S Tripathi 13, BI D Mayur Vihar New delhi

a. To display the RecIC, Sendername, SenderAddress, RecName, RecAddress for every


Recipient
b. To display Recipient details in ascending order of RecName
c. To display number of Recipients from each city
d. SELECT A.SenderName, B.RecName From Sender A, Recipient B Where A.SenderID =
B.SenderID AND B.RecCity =’Mumbai’;
e. SELECT RecName, RecAddress From Recipient Where RecCity NOT IN (‘Mumbai’,
‘Kolkata’) ;

ANs.
a. Select R.RecIC, S.Sendername, S.SenderAddress, R.RecName, R.RecAddress from
Sender S, Recepient R where S.SenderID=R.SenderID ;
b. SELECT * from Recipent ORDER By RecName;
c. SELECT COUNT( *) from Recipient Group By RecCity;
d.
A.SenderName B.RecName
R Jain H Singh
S Jha P K Swamy
e.
RecName RecAddress
S Mahajan 116, A Vihar
S Tripathi 13, BID, Mayur Vihar

40 Write a program to insert/append a record in the binary file “student.dat”. 5

Or
Write a program to read a record from the binary file “student.dat”

You might also like