Question Paper Computer Science Class 12
Question Paper Computer Science Class 12
Q No. Answer Total Name of Web browsers: Google Chrome, Mozilla Firefox
Marks
1 mark for any one correct difference and 1/2 mark for each two correct
1 a. per%marks 1 examples
2 b. list.append(element) 1 20 num1, num2 = 10, 45 2
while num1 % num2 == 0:
3 b. lcomme T 1 num1+= 20
4 b. One block of except statement cannot handle multiple exceptions 1 num2+= 30
else:
5 c. Statement 3 1 print('hello')
3 4
(b) Stu_Stk=[]
DESC or DESCRIBE command
1 mark for correct answer def Push_elements(Stu_Stk, Stu_dict):
for Stu_ID, marks in Stu_dict.items():
28 def Count(): 3 if marks[2]>=80:
F=open('Gratitude.txt') Stu_Stk.append(Stu_ID)
T=F.readlines()
X=1 def Pop_elements(Stu_Stk):
for i in T: while len(Stu_Stk)>0:
print('Line',X,':',i.count('e')) print(Stu_Stk.pop())
X=X+1 if not Stu_Stk:
F.close() print('Stack Empty')
Count()
Push_elements(Stu_Stk, Stu_dict)
½ mark for function header Pop_elements(Stu_Stk)
½ mark for opening and closing the file
½ mark for reading lines 1.5 marks for correct implementation of Push_elements()
½ mark for loop 1.5 marks for correct implementation of Pop_elements()
½ mark for count function/or any other alternate correct statement(s) 31 import csv 4
½ mark for counter def maxsalary():
f=open('record.csv', 'r')
OR reader=csv.reader(f)
skip_header = True
max= 0
def Start_with_I():
for row in reader:
F=open('Gratitude.txt')
if skip_header:
T=F.readlines()
skip_header = False
for i in T:
else:
if i[0] in 'Ii':
if(int(row[3])>max):
print(i,end='')
max=int(row[3])
F.close()
rec=row
Start_with_I()
print('Row with the highest salary : ', rec)
f.close()
½ mark for function header maxsalary()
½ mark for opening and closing the file
½ mark for reading lines ½ mark for importing module
½ mark for loop ½ mark for function definition
½ mark for if condition ½ mark for opening and closing file
½ mark for print statment ½ for reader object
29 (i) Candidate Keys : ADMNO, ROLLNO 3 ½ for skipping first row (i.e. header)
1 mark for calculating maximum salary
1 mark for correctly writing both names of candidate keys. OR ½ mark for ½ mark for displaying record having maximum salary
specifying any one candidate key correctly. 32 import pickle 4
def expensiveProducts():
with open('INVENTORY.DAT', 'rb') as file:
(ii) Degree-8, Cardinality=4 expensive_count = 0
while True:
try:
½ mark for degree and ½ mark for cardinality product_data = pickle.load(file)
product_id, product_name, quantity, price = product_data
(iii) Update result set SEM2=SEM2+.03*SEM2 where SEM2 between 70 if price > 1000:
print("Product ID:", product_id)
and 100; expensive_count += 1
except EOFError:
½ mark for writing Update result set part correctly break
½ mark for writing SEM2=SEM2+.03*SEM2 where SEM2 between 70 and print("Total expensive products: ", expensive_count)
100; correctly.
expensiveProducts()
30 Stu_dict={5:(87,68,89), 10:(57,54,61), 12:(71,67,90), 3
14:(66,81,80), 18:(80,48,91)} ½ mark for function definition
5 6
½ mark for opening and closing file while True:
½ mark for correct try and except block data = pickle.load(In_file)
1.5 mark identifying and displaying details of expensive products if data[3] == 'DELHI' and data[4] == 'MUMBAI':
pickle.dump(data,out_file)
1 mark for displaying count of expensive products except:
33 i. The most appropriate location of the server inside the MUMBAI 5 In_file.close()
out_file.close()
campus is ADMIN building due to the maximum number of computers
in it. COPY_REC()
½ mark for mentioning the branch and ½ mark for proper justification
½ mark for function definion
ii. Cable Layout ½ mark for correctly opening and closing file
Star Topology (Based on Bus Topology (Based on ½ mark for correct try and except block
server location) minimum distance between 1.5 marks for writing required data in RECORD.DAT
branches)
OR
i.
Binary CSV
1. pickle module to be used 1. csv module is used
2. Data is stored in binary 2. Data is stored in tabular
format(0s and 1s) and is not fashion and comma
in human readable form using separated by default. The
any plain text editor. file can be read by any
spreadsheet software or text
editor.
1 mark for drawing any valid cable layout 3. File extension .dat/.pdf/.exe 3. File extension .csv
etc.
iii. Switch or Hub
1mark for suggesting the correct device 2 marks for mentioning two correct differences.
OR
iv. c. Video Conferencing 1 marks for mentioning only one correct differences.
1 mark for correct answer
ii.
v.
(a) WAN import pickle
(b) LAN
def findBook(price):
½ mark for mentioning WAN and ½ mark for mentioning LAN
with open('BOOK.DAT', 'rb') as file:
34 i. 5 while True:
seek() tell() try:
book_record = pickle.load(file)
Purpose Repositions the file pointer to a Returns the current for item in book_record:
specific location within a file position of the file book_price = book_record[item][2]
pointer if book_price >= price:
Syntax seek(offset [,reference point]) tell() print(item, book_record[item])
Parameters Requires specifying the offset Requires no except EOFError:
and an optional reference point parameters break
findBook(50)
2 marks for mentioning two correct differences.
OR ½ mark for function definion
1 marks for mentioning only one correct differences. ½ mark for correctly opening and closing file
ii. ½ mark for correct try and except block
import pickle
def COPY_REC():
1.5 marks for displying required records
In_file = open('FLIGHT.DAT','rb') 35 (i) 5
out_file = open('RECORD.DAT','wb')
try:
7 8
SQL constraints are used to specify rules for the data in a table. Constraints
are used to limit the type of data that can go into a table.
Constraints –
NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table
OR
(i)
Candidate Key: A candidate key is a set of attributes in a relation that can
uniquely identify each tuple (row). A relation can have multiple candidate
keys, but only one of them is chosen as the primary key.
Alternate Key: An alternate key is a candidate key that is not selected as the
primary key.
(ii)
a) import mysql.connector as mysql
b) mycursor = con1.cursor()
c) query = 'SELECT * FROM ITEM where Price > {}'.format(5000)
d) data = mycursor.fetchall()