0% found this document useful (0 votes)
18 views7 pages

Xii PB2 MS CS Set2

Uploaded by

ram priya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Xii PB2 MS CS Set2

Uploaded by

ram priya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

KENDRIYA VIDYALAYA SANGATHAN, AGRA REGION

Class: XII Session: 2023-24


Computer Science (083)
Second Pre Board Exam 2023 (Theory)
Time allowed: 3 Hours Maximum Marks: 70

Ques Question and Answers Total


No Marks
SECTION A 1
1 d)print() 1
2 True 1
3 c)23.0 1
4 d) None of the above 1
5 c) ALTER table emp ADD bonus int; 1
6 (a)32 bits 1
7 d) error 1
8 b) List 1
9 b)(['salary', 'dept', 'age', 'name']) 1
10 a) 3,4 1
11 B) Modem 1
12 a)continue 1
13 a) OverFlowError 1
14 A. Fixed, Variable 1
15 a)SMTP 1
16 a) fp.seek(offset, 0) 1
17 (a) Both A and R are true and R is the correct explanation for A 1
18 A. A is True but R is False 1
SECTION B
19 (a) TCP-Transmission Control Protocol/ Internet Protocol 2
VoIP-Voice over Internet Protocol
(b) FTP is used for sharing files over internet.
OR
(a) One mark for any one correct difference.
(b) One mark for any one correct difference.
20 def sum(arg1,arg2): 2
total=arg1+arg2 ; # No need of semicolon at two places
print(”Total:”,total)
return total ; # wrong indentation for return statement
a=sum(10,20) #Value returned from function is not received
(½ mark for each correct correction made and underlined.)
21 ['E', 'a', 'i', 'a', 'i', 'n'] 2
22 def change(L): 2
EL=[]
OL=[]
for I in range(0,len(L)):
if L[i]%2==0:
EL.append(L[i])
else:
OL.append(L[i])
print(“List of even elements:”,EL)
print (“List of odd elements:”,OL)
Note: Any other relevant and correct code may be marked
OR
def INDEX_LIST(S):
indexList=[]
for i in range(len(S)):
if S[i] in 'aeiouAEIOU':
indexList.append(i)
return indexList
Note: Any other relevant and correct code may be marked
23 (i) L1.insert(1,150) 2
(ii) message.upper( )
OR
import math
print(math.factorial(5))
24 SQL querry to create the table HRDATA: 2
CREATE TABLE HRDATA
(Ecode int, Ename char(50),Desig char(5),remn int);
SQL querry to insert given data in to the table HRDATA:
INSERT INTO HRDATA
VALUES(80008,"Arjun","Admin",55000);
OR
SQL querry to remove the column Quantity from table CHStore:
ALTER TABLE CHStore drop column Quantity;
SQL querry to display the structure of the table CHStore:
DESC CHStore; or DESCRIBE CHStore;
25 22 # 40 # 9 # 13 # 2
(½ mark for the correct digit with a #)
SECTION C
26 New String is: iNdiA%**** 3
27 a)475 3
b)6
c)68
1 mark for each correct answer.
28 def count_W_H(): 3
f = open (“Country.txt”, “r”)
W,H = 0,0
r = f.readlines()
for x in r:
if x[0] == “W” or x[0] == “w”:
W=W+1
elif x[0] == “H” or x[0] == “h”:
H=H+1
f.close()
print (“W or w :”, W)
print (“H or h :”, H)
OR
def countwords():
s = open("Quotes.txt","r")
f = s.read()
z = f.split ()
count = 0
for i in z:
count = count + 1
print ("Total number of words:", count)
Note: Using of any correct code giving the same result is also accepted.
29 a) UPDATE EMPLOYEE 3
SET SALARY=SALARY+(SALARY*.05)
WHERE JOB TYPE=”Clerk”;
b) SELECT * FROM EMPLOYEE WHERE DATEOFJOIN
BETWEEN ‘1985-01-01’ AND ‘2000-03-31’;
c) DELETE FROM EMPLOYEE WHERE JOB TYPE=’Manager’;
30 status=[] 3
def Push_element(cust):
if cust[2]=="Goa":
L1=[cust[0],cust[1]]
status.append(L1)
def Pop_element ():
num=len(status)
while len(status)!=0:
dele=status.pop()
print(dele)
num=num-1
else:
print("Stack Empty")
(1.5 marks for correct Push_element() and 1.5 marks for correct
Pop_element())
SECTION D
31 a) SELECT COUNT(*) FROM EMP GROUP BY DEPTNO; 4
b) SELECT JOB, COUNT(*) FROM EMP WHERE COUNT(*)<3
GROUP BY JOB;
c) SELECT ENAME, DNAME FROM EMP,DEPT
WHERE EMP.DEPTNO=DEPT.DEPTNO;
d) SELECT MAX(SAL) FROM EMP WHERE JOB=‘MANAGER’;
32 import csv 4
def ADDPROD():
fout=open("product.csv","a",newline="\n")
wr=csv.writer(fout)
prodid=int(input("Enter Product id :: "))
name=input("Enter Product name : ")
price=int(input("Enter Product Price : "))
lst=[ prodid, name, price]
wr.writerow(lst)
fout.close()
def COUNTPROD():
fin=open("product.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTR()
(½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and COUNTR()
½ mark for function call statements)
SECTION E
33 (a) Suggest a cable layout of connection between the blocks. 5

(b) Ans : HR centre because it consists of the maximum number of


computers to house the server.
(c) Ans: Switch/ Hub should be placed in each of these blocks.
(d) Ans : MAN
(e) Ans : Bus

34 (i) Binary file: 5


• Extension is .dat
• Not human readable
• Stores data in the form of 0s and 1s
CSV file
• Extension is .csv
• Human readable
• Stores data like a text file
(ii) import pickle
def AddStudents():
F= open("STUDENT.DAT",'wb')
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
pickle.dump(L,F)
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
R = pickle.load(F)
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent =",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("No student has percentage more
than 75")
print("average percent of class = ", Total /
Countabove75)
AddStudents()
GetStudents()
OR
(a) Advantage: Faster and no conversion required
Disadvantage: Can’t read by users directly
(b) import pickle
def createFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
def CountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
35 (i) For each attribute of a relation, there is a set of permitted values, 5
called Domain of that attribute.
Example: any valid example
(ii) import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",
password="root@123", database="management")
mycursor= con1.cursor()
print("Employees with salary greater than 53500 are : ")
mycursor.execute("select * from Employees where
EmpSalary >53500")
data = mycursor.fetchall()
for i in data:
print(i)
print()
OR
(i) Degree is the no of columns in a relation while
Cardinality is the no of tuples in a relation.
Any example
(ii) import mysql.connector as mydb
mycon = mydb.connect (host = “localhost”, user = “root”,
passwd = “system”, database = “Admin”)
cursor = mycon.cursor ( )
sql = “UPDATE TRAINER SET SALARY = SALARY + 2000
WHERE TNAME = ‘SUNAINA’”
cursor. execute(sql)
mycon.commit ( )
mycon.close( )

You might also like