12-CBSE-ComputerScience-Set-3
12-CBSE-ComputerScience-Set-3
Computer Science
XII – STANDARD (CBSE)
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 3 questions (31 to 33). Each question carries 5 Marks.
7. Section E, consists of 2 questions (34 to 35). Each question carries 4 Marks.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. State True or False. 1
“Comments are not executed by interpreter”
6. Which of the following modes in Python creates a new file, if file does not exist and 1
overwrites the content, if the file exists?
(a) r+
(b) r
(c) w
(d) a
7. Fill in the blank: ___________ is not a valid built-in function for list manipulations. 1
(a) count ()
(b) length ()
(c) append ()
(d) extend()
9. Which of the following statement(s) would give an error after executing the 1
following code?
S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S) # Statement 5
(a) Statement 2
(b) Statement 3
(c) Statement 4
(d) Statement 3 and 4
10. Fill in the blank: In a relational model, tables are called _________, that store data 1
for different columns.
(a) Attributes
(b) Degrees
(c) Relations
(d) Tuples
2
12. Fill in the blank: _________ statement of SQL is used to insert new records in a 1
table.
(a) ALTER
(b) UPDATE
(c) INSERT
(d) CREATE
(a) 6.5
(b) 4.0
(c) 6.0
(d) 4 15.
15. Which of the following functions is a valid built-in function for both list and 1
dictionary datatype?
(a) items()
(b) len()
(c) update()
(d) values()
16. fetchone() method fetches only one row in a ResultSet and returns a __________. 1
(a) Tuple
(b) List
(c) Dictionary
(d) String
Q. 17 and 18 are Assertion (A) and Reasoning (R) based questions. Mark the
correct choice as
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).
(b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
(c) (A) is true but (R) is false.
(d) (A) is false but (R) is true.
Reasoning (R): A stack is an ordered linear list of elements that works on the
principle of First In First Out (FIFO).
18. Assertion (A): readlines() reads all the lines from a text file and returns the lines 1
along with newline as a list of strings.
3
Reasoning (R): readline() can read the entire text file line by line without using any
looping statements.
SECTION B
19. Ravi, a Python programmer, is working on a project in which he wants to write a 2
function to count the number of even and odd values in the list. He has written the
following code but his code is having errors. Rewrite the correct code and underline
the corrections made.
define EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
else:
odd_no+=1
print(even_no, odd_no)
20. (a) Write any two differences between Fiber-optic cable and Coaxial cable. 2
OR
(b) Write one advantage and one disadvantage of wired over wireless
communication.
22. Explain the usage of HAVING clause in GROUP BY command in RDBMS with 2
the help of an example.
24. (a) Write the output of the Python code given below: 2
g=0
def fun1(x,y):
global g
g=x+y
return g
def fun2(m,n):
global g
g=m-n
return g
4
k=fun1(2,3)
fun2(k,7)
print(g)
OR
SECTION C
26 a) Consider the following tables Student and Sport: 3
Table: Student
ADMNO NAME CLASS
1100 MEENA X
1101 VANI XI
Table: Sport
ADMNO GAME
1100 CRICKET
1103 FOOTBALL
What will be the output of the following statement?
SELECT * FROM Student, Sport;
OR
b) Write the output of the queries (i) to (iv) based on the table, GARMENT
given below:
TABLE: GARMENT
GCODE TYPE PRICE FCODE ODR_DATE
G101 EVENING GOWN 850 F03 2008-12-19
G102 SLACKS 750 F02 2020-10-20
G103 FROCK 1000 F01 2021-09-09
G104 TULIP SKIRT 1550 F01 2021-08-10
G105 BABY TOP 1500 F02 2020-03-31
G106 FORMAL PANT 1250 F01 2019-01-06
5
(i) SELECT DISTINCT(COUNT(FCODE))FROM GARMENT;
(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM GARMENT
GROUP BY FCODE HAVING COUNT(*)>1;
(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE >'2021-02-
01' AND PRICE
(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';
27 a) Write a function in Python that displays the book names having y in their 3
name from a text file Bookname.txt
Example: if the file Bookname.txt contains the names of following books:
One Hundred Years of Solitude
The Diary of a Young Girl
On the Road
OR
b) Write a function RevString() prints the words The rest of the content is
displayed normally.
Example:
If content in the text file is:
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be:
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(words ‘OPEN’ and ‘OPERATING’ are displayed in reverse order)
28 Write the output of any three SQL queries (i) to (iv) based on the tables 3
COMPANY and CUSTOMER given below:
Table: COMPANY
CID C_NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY CHENNAI MOBILE
666 DELL DELHI LAPTOP
Table: CUSTOMER
CUSTID CID NAME PRICE QTY
C01 222 ROHIT SHARMA 70000 20
C02 666 DEEPIKA KUMARI 50000 10
C03 111 MOHAN KUMAR 30000 5
C04 555 RADHA MOHAN 30000 11
6
i) SELECT PRODUCTNAME, COUNT (*) FROM COMPANY GROUP
BY PRODUCTNAME HAVING COUNT (*)> 2;
ii) SELECT NAME, PRICE, PRODUCTNAME FROM COMPANY C,
CUSTOMER CT WHERE C.CID = CU.CID AND C_NAME =
'SONY';
iii) SELECT DISTINCT CITY FROM COMPANY;
iv) SELECT * FROM COMPANY WHERE C_NAME LIKE '%ON%';
Example:
L = [10,20,30,10,40]
Number to be searched = 10
List after replacement:
L = [0,20,30,0,40]
For example:
If the lists of courses details are:
[“MCA”, 200000, 3]
[“MBA”, 500000, 2]
[“BA”, 100000, 3]
SECTION D
31 ABC Consultants are setting up a secure network for their office campus at Noida 5
for their day-to-day office and web-based activities. They are planning to have
connectivity between three buildings and the head office situated in Bengaluru. As
a network consultant, give solutions to the questions (i) to (v), after going through
the building locations and other details which are given below:
7
Distance between various blocks/locations:
Building Distance
Number of computers
Building 1 = 25
Building 2 = 51
Building 3 = 150
Head Office = 10
i) Suggest the most suitable place to install the server for this organization.
Also, give reason to justify your suggested location.
ii) Suggest the cable layout of connections between the buildings inside the
campus.
iii) Suggest the placement of the following devices with justification:
Switch Repeater
iv) The organization is planning to provide a high-speed link with the head
office situated in Bengaluru, using a wired connection. Suggest a
suitable wired medium for the same.
v) The System Administrator does remote login to any PC, if any
requirement arises. Name the protocol, which is used for the same.
32 (a) What possible output(s) are expected to be displayed on screen at the time 5
of execution of the following code?
import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)
print(S[f], S[s],sep=":")
Options:
(I) Pencil:Book
(II) Pencil:Book Eraser:Bag
(III) Pen:Book Bag:Book
(IV) Bag:Eraser
OR
8
(b) Predict the output of the code given below :
text="LearningCS"
L=len(text) ntext=""
for i in range (0,L):
if text[i].islower():
ntext=ntext+text[i].upper()
elif text [i].isalnum():
ntext=ntext+text[i 1]
else: ntext=ntext+'&&'
print(ntext)
33 a) Write a point of difference between append (a) and write (w) modes in a 5
text file.
Write a program in Python that defines and calls the following user defined
functions:
(i) Add_Teacher(): It accepts the values from the user and inserts record
consists of a list with field elements as T_id, Tname and desig to
store teacher ID, teacher name and designation respectively.
(ii) Search_Teacher(): To display the records of all the PGT
(designation) teachers.
OR
b) Write one point of difference between seek() and tell() functions in file
handling. Write a program in Python that defines and calls the following
user defined functions:
(i) Add_Device(): The function accepts and adds records of the
peripheral devices to the csv file “peripheral.csv”. Each record
consists of a list with field elements as P_id, P_name and Price to
store peripheral device ID, device name, and price respectively.
(ii) (ii) Count_Device(): To count and display number of peripheral
devices, whose price is less than < 1000.
SECTION E
34 The ABC Company is considering to maintain their salespersons records using SQL 4
to store data. As a database administrator, Alia created the table Salesperson and
also entered the data of 5 Salespersons.
Table: Salesperson
S_ID S_NAME AGE S_AMOUNT REGION
S001 SHYAM 35 20000 NORTH
S002 RISHABH 30 25000 EAST
S003 SUNIL 29 21000 NORTH
S004 RAHIL 39 22000 WEST
S005 AMIT 40 23000 EAST
9
OR (Option for part iii only)
iii) Write the statement to:
(a) Delete the record of salesman RISHABH, as he has left the company.
(b) Remove an attribute REGION from the table.
35 Atharva is a programmer, who has recently been given a task to write a Python code 4
to perform the following binary file operation with the help of a user defined
function/module:
Copy_new() : to create a binary file new_items.dat and write all the item details
stored in the binary file, items.dat, except for the item whose item_id is 101. The
data is stored in the following format:
{item_id:[item_name,amount]}
He has succeeded in writing partial code and has missed out certain statements.
Therefore, as a Python expert, help him to complete the code based on the given
requirements:
i) Which module should be imported in the program? (Statement 1)
ii) Write the correct statement required to open the binary file "items.dat".
(Statement 2)
iii) Which statement should Atharva fill in Statement 3 to open the binary
file "new_items.dat" and in Statement 4 to read all the details from the
binary file "items.dat".
iv) What should Atharva write in Statement 5 to apply the given condition
and in Statement 6 to write data in the binary file "new_items.dat".
10