CS MS Set-1
CS MS Set-1
CS (SET-1)
Instructions:-
●This question paper contains 37 questions.
●All questions are compulsory. However, internal choices have been provided in
some questions. Attempt only one of the choices in such questions
●The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
1. False (1)
3. (D)True (1)
(1 mark for correct answer)
5. (A) () (1)
(1 mark for correct answer)
PAGE NO. 1 OF 11
8. (D) None of the above (1)
(1 mark for correct answer)
9. (A) Cannot have NULL values and can have UNIQUE values. (1)
(1 mark for correct answer)
14. (C) Display name of students whose name has ‘ar’ anywhere in name. (1)
(1 mark for correct answer)
20. (A) Both A and R are true and R is the correct explanation for A. (1)
(1 mark for correct answer)
PAGE NO. 2 OF 11
22. “in” operator results in True/False after checking a value in a range of (2)
values. (1 mark for correct answer)
“ONE” & [1,2,3] (1/2 mark for each correct answer)
PAGE NO. 3 OF 11
28. (A) MODEM stands Modulation-Demodulation. MODEM is used to connect (2)
to Internet through the conversion of digital signals into analog signals and
vice-versa.
(1 mark for each correct full form)
(1 mark for each correct use of MODEM)
OR
(B) XML stands for Extensible Markup Language. XML allows the
development more new markups/elements while HTML works only on the
already defined markups.
(1 mark for each correct full form)
(1 mark for each correct benefit of XML over HTML)
Q. No. Section-C ( 3 x 3 = 9 Marks) Marks
29. (3)
PAGE NO. 4 OF 11
(1/2 mark for correct function header)
(1/2 mark for correct opening of file)
(1/2 mark for correctly reading from the file)
(1 mark for any correct logic & it’s code)
(1/2 mark for printing correct output)
(II)
def Pop_Emp(Emp_Stack):
if not Emp_Stack:
print("Underflow")
else:
return(Emp_Stack.pop())
(III)
def Peep(Emp_Stack):
if not Emp_Stack:
print("None")
else:
print(Emp_Stack[-1])
(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)
PAGE NO. 5 OF 11
OR
(B)
(I)
def Push_State(D_STATE):
for I in D_STATE:
if len(D_STATE[I])<10:
STATE.append(D_STATE[I])
(II)
def Pop_State():
if not STATE:
print("Empty")
else:
return(STATE.pop())
(III)
def Disp_State():
if not STATE:
print("None")
else:
print(STATE [-1:-len(STATE)-1:-1])
(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)
PAGE NO. 6 OF 11
32. (A) Write SQL queries for the following: (4)
I. SELECT * FROM SURGERY ORDER BY STARTDATE DESC;
II. SELECT SUM(FEES) FROM SURGERY WHERE OTNO IS NULL;
III. SELECT SID, FEES FROM SURGERY WHERE SNAME LIKE
“D%”;
IV. SELECT COUNT(*) FROM SURGERY WHERE FEES<12000 AND
OTNO != 301;
(4 x 1 mark for each correct query)
OR
(B) Write the output of the given below SQL queries:-
I. DISTINCT(OTNO)
302
NULL
301
II. OTNO COUNT(*) MIN(FEES)
302 2 15000
III. SNAME
HEART
STOMOCH
IV. AVG(FEES)
16500
(4X1 mark each for correct output)
PAGE NO. 7 OF 11
(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)
(II)
import csv
def Count_City():
f=open("Population.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
f.close()
34. Write SQL commands for the following queries (i) to (iv) based on the (4)
relations TRAINER & COURSE given below:
I. SELECT * FROM TRAINER WHERE CITY IS ”CHENNAI”;
II. SELECT CITY, COUNT(*) FROM TRAINER GROUP BY CITY;
III. SELECT * FROM COURSE WHERE FEES > 12000 AND
CNAME LIKE “%A”;
PAGE NO. 8 OF 11
IV. (A) SELECT T.TNAME, C.CNAME FROM TRAINER T,
COURSE T WHERE T.TID=C.TID AND C.FEES<10000;
OR
(B) SELECT * FROM TRAINER, COURSE;
(4X1 mark each for correct QUERY)
PAGE NO. 9 OF 11
import pickle
def NewTest():
Tid = int(input("Enter Test ID: "))
Sub= input("Enter Subject Name of Test: ")
MM = int(input("Enter Max. Marks of Test: ") )
SM = float(input("Enter Marks Scored in the Test: "))
REC = [Tid, Sub, MM, SM]
F=open(“TEST.DAT”,”ab”)
pickle.dump(REC, F)
F.close()
(II)
import pickle
def UpdateMM(Sub):
file=open(“TEST.DAT”,”rb”)
while True:
try:
rec = pickle.load(file)
if rec[1] == Sub:
rec[2]+=10
file.seek(-len(rec))
pickle.dump(rec, file)
print(“Max. Marks updated”)
except EOFError:
break # End of file reached
(III)
import pickle
def DisplayAvgMarks(Sub):
sum=count=0
try:
with open('TEST.DAT', 'rb') as file:
PAGE NO. 10 OF 11
while True:
try:
rec = pickle.load(file)
if rec[1] == Sub: # Check the subject
sum+=rec[3]
count+=1
except EOFError:
print(“Average marks of “, Sub, “ are : “, sum/count)
break # End of file reached
except FileNotFoundError:
print("No Test data found. Please add Test data first.")
***************
PAGE NO. 11 OF 11