MS-1PB-CS-2024 Set 2
MS-1PB-CS-2024 Set 2
CLASS:- 12
27. (2)
(B) [2,7,4]
(D) [3,1,6]
½ mark for each option
Maximum possible value of b=8
1 mark for correct answer.
28. def showGrades(S): #s1 (2)
avg=0 #s2
for a in S:
avg=S[a][0]+S[a][1]+S[a][2]
avg= avg/3
if avg>=90:
print(a, ‘ – A‘)
elif avg>=60:
print(a, ‘ – B‘)
else:
print(a, ‘ – C‘)
OR
Write a Python function that find and displays all the words beginning with ‘w’
or ‘W’ from a text file “Paragraphs.txt”
def findWordswithW(): # ½ mark for correct header
with open(‘Paragraphs.txt’,’r’) as f: # ½ mark for correct open statement
b=f.read().split()
for word in b: # 1 mark for correct for loop
if word[0].lower()==’w’: # ½ mark for correct condition
print(word, end=’ ’) # ½ mark for correct print statement
(ii)
HIRE_DATE
=========
RAKSHIT
RASHMI
SULEKHA
(iii)
AVG(SALARY)
============
11000
(iv)
F_ID FNAME LNAME HIRE_DATE SALARY
==============================================
104 RAKSHIT SONI 18-05-2001 14000
105 RASHMI MALHOTRA 11-09-2004 11000
34. (4)
Write SQL queries for the following:
(i) SELECT PName, BName FROM PRODUCT P, BRAND B WHERE
P.BID=B.BID;
(ii) DESC PRODUCT;
(iii) SELECT BName, AVG(Rating) FROM PRODUCT P, BRAND B
WHERE P.BID=B.BID GROUP BY BName HAVING Name='Medimix'
OR BName='Dove';
(iv) SELECT PName, UPrice, Rating FROM PRODUCT ORDER BY
Rating DESC;.
mycursor=con1.cursor()
rno= int(input("Enter Roll Number:: "))
name = input("Enter the name:: ")
DOB=input("Enter date of birth:: ")
fee= float(input("Enter Fee:: "))
con1.close()
Q No. Section-E ( 5 x 2 = 10 Marks) Marks
36. i) 5
with open(‘Sport.dat’, ‘wb’) as f: # 1 mark for correct syntax
ii)
import pickle
def AddTeam():
with open((‘Sport.dat’, ‘ab’) as f:
#1 mark for correctly opening the file
iii)
def copyData():
fObj = open("SPORT.DAT", "rb")
f0bj1 open("BASKET.DAT", "wb")
# ½ mark for correctly opening each file
cnt=0
try:
while True:
data= pickle.load(fobj)
print (data)
if data [0] == "Basket Ball":
pickle.dump(data, fobj1)
cnt+=1
except:
fobj.close()
fobjl.close()
return cnt
# 1 mark for correct load statement and dumping data to file
37. (5)
a) HR Center, as it has the maximum number of computers.
b)
Bus Topology
c) Switch
d) Repeater is not required as the distances between any two blocks is not more
than 90m. However if it is required to connect Law block to HR Center then
Repeater will be required between those blocks as the distance is 105m.
e) WAN will be formed, because the distance is too big to be considered a
MAN
1 mark for each correct answer.