XII_Computer Science_SetC_MS_Mod
XII_Computer Science_SetC_MS_Mod
3 (b) (i),(ii) 1
4 1
(b)5 6 7 8
12 3 1
13 (c) Distinct 1
14 (a) AND,OR,NOT 1
1
15 (b) Count(*) 1
16 (a) Equijoin 1
17 (b) Fiber optic cable 1
18 (c) MAC 1
19 (c) TELNET 1
20 (A)Both A and R are true and R is the correct explanation for A 1
21 (b) Both A and R are true and R is not the correct explanation for A 1
SECTION - B
22 138 2
23 The smallest individual unit in a program is known as a Token or a 2
lexical unit.
Python has following types of tokens:
(i) Keywords (ii) Identifiers(Names) (iii) Literals (iv) Operators (v)
Punctuators
24 I.(a)L1.count(3) (1+1)
OR
(b).L1.sort()
II. (a)L1.extend(L2)
(b) L2.reverse()
25 (a), (c) (½ x 2 = 1 Mark) 2
Minimum and maximum possible values of the variable b: 1,6 (½ x 2 =
1 Mark)
26 def revNumber(num): 2
rev = 0
while num > 0:
rem = num % 10
rev = rev * 10 + rem
num = num // 10
return rev
print(revNumber(1234))
#solution 2
def COUNTLINES():
consonants = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
SECTION – D
32. A) 4
(I) ALTER TABLE Teacher ADD CONSTRAINT UNIQUE (ID);
(II) SELECT NAME , DEPARTMENT AND HIREDATE FROM TEACHER
ORDER BY HIREDATE DESC;
(III) SELECT COUNT(*), SUM(SALARY) FROM TEACHER GROUP BY
DEPARTMENT;
(IV) SELECT * FROM Teacher WHERE CATEGORY IN ('PRT', 'PGT')
AND SALARY IS NULL;
OR
B)
(I)
DEPARTMEN GENDE
ID NAME HIREDATE CATEGORY SALARY
T R
1980-05-
3 SANJANA ENGLISH PGT F NULL
16
(II)
MAX(HIREDATE MIN(HIREDATE
SUM(SALARY)
) )
106500 1994-03-17 1980-11-17
(III)
DEPARTMEN GENDE
ID NAME HIREDATE CATEGORY SALARY
T R
5 AMAN HINDI 1990-01- PRT F NULL
5
08
(IV)
CATEGORY
TGT
PRT
33 import csv 4
def inser_ROLL():
fout=open("marks.csv","a",newline="\n")
wr=csv.writer(fout)
rollno=int(input("Enter Roll number "))
mark=float(input("Enter mark :: "))
lst=[rollno,mark]
wr.writerow(lst)
fout.close()
def read_ROLL():
fin=open("marks.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(“No.of records=”:,len(d))
for i in data:
print(i)
fin.close()
(2marks for insert function , 2marks for display)
34 (i) SELECT Book.Book_Id,Book_Name,Quantity_Issued FROM 4
Books.Book_Id=Issued.Book_Id;
(ii) SELECT Book_Name FROM Books WHERE Type=”Text”;
(iii) UPDATE Book SET Price=Price+50 WHERE Publishers=”EPB”;
(iv)INSERT INTO Issued VALUES (“F0003”,1)
OR
(iv) SELECT * FROOM BOOKS,ISSUED;
(each 1mark for correct query)
35 def Add_Item(): 4
import mysql.connector as mycon
mydb=mycon.connect(host="localhost",user="root",
passwd="Stock",database="ITEMDB")
mycur=mydb.cursor()
6
no=int(input("Enter Item Number: "))
nm=input("Enter Item Name: ")
pr=float(input("Enter price: "))
qty=int(input("Enter qty: "))
query="INSERT INTO STOCK VALUES ({},'{}',{},{})"
query=query.format(no,nm,pr,qty)
mycur.execute(query)
mydb.commit()
mycur.execute("select * from stationery where price>200")
for rec in mycur:
print(rec)
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
36 import pickle 5
(I) def append():
with open("Books.dat",'ab') as f:
B_id=int(input("Enter Book ID: "))
B_nm=input("Enter Book name: ")
B_at=input("Enter Author: ")
B_ed=input("Enter Edition: ")
rec=[B_id,B_nm,B_at,B_ed]
pickle.dump(rec,f)
(ii)
import pickle
def update():
f = open("books.dat", 'rb+')
s=0
try:
while True:
book = pickle.load(f)
if book.edition < 5:
book.edition += 1
7
s=1
if s == 1:
f.seek(0)
pickle.dump(book, f)
print(f"Updated edition for book ID {book.book_id}.")
else:
print("No books with edition less than 5 found to update.")
except EOFError:
f.close()
(III)
import pickle
def display():
with open("Books.dat",'rb') as f:
while True:
try:
rec=pickle.load(f)
if rec[2].upper()==”SAM”:
print(rec)
except EOFError:
break
(1/2 mark of import pickle)
(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using
dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
37 a) The most suitable place / block to house the server of this
organisation would be X Building, as this block contains the maximum
number of computers, thus decreasing the cabling cost for most of the
computers as well as increasing the efficiency of the maximum
computers in the network.
(b)
c)The type of network that shall be formed to link the sale counters
situated in various parts of the same city would be a MAN, because
8
MAN (Metropolitan Area Networks) are the networks that link
computer facilities within a city.
(d)In layout between X&Z,X&W.In layout2 between Y and Z.Because
distance is more than 90m.
e)switch
(each 1 mark for correct answer)