ComputerScience-SQP) 2024 Preboard
ComputerScience-SQP) 2024 Preboard
Thisquestionpapercontainsfivesections,SectionAtoE.
Allquestionsarecompulsory.
SectionAhave18questionscarrying01markeach.
SectionBhas07VeryShortAnswertypequestionscarrying02markseach.
SectionChas05ShortAnswertypequestionscarrying03markseach.
SectionDhas03LongAnswertypequestionscarrying05markseach.
SectionEhas02questionscarrying04markseach.Oneinternalchoiceis given in Q35
against part c only.
AllprogrammingquestionsaretobeansweredusingPythonLanguageonly.
SECTIONA
1. State True or False 1
“Variable declaration is implicitin Python.”
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500,"Pass_Marks":165}
(a) True
(b) False
(c) NONE
(d) NULL
5. Selectthecorrectoutputofthecode: 1
a="Year2022atAllthe best"
1
a=a.split('2')
b=a[0]+"."+a[1]+"."+a[3]
print (b)
6. Whichofthefollowingmodeinfileopeningstatementresultsor generates 1
an error if the file does not exist?
7. Fillintheblank: 1
commandisusedtoremoveprimarykeyfromthetableinSQL.
8. Whichofthefollowingcommandswilldeletethe tablefromMYSQL 1
database?
(a) DELETETABLE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
9. Whichofthefollowingstatement(s)wouldgiveanerrorafter 1
executing the following code?
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement4and5
10. Fillintheblank: 1
isanon-keyattribute,whosevaluesarederivedfromthe
primary key of some other table.
(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey
2
(d)Alternate Key
11. Thecorrectsyntaxofseek()is: 1
(a) file_object.seek(offset[,reference_point])
(b) seek(offset[,reference_point])
(c) seek(offset,file_object)
(d) seek.file_object(offset)
12. Fillintheblank: 1
The SELECT statement when combined with clause,
returns records without repetition.
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13. Fillintheblank: 1
isacommunicationmethodologydesignedtodeliverbothvoice
and multimedia communications over Internet protocol.
14. WhatwillthefollowingexpressionbeevaluatedtoinPython? 1
print(15.0/4+(8+ 3.0))
(a) host
(b) database
(c) user
(d) password
3
(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTrue butRisFalse
(d) AisfalsebutRisTrue
18. Assertion(A):CSV(CommaSeparatedValues)isafileformatfordata 1
storage which looks like a text file.
Reason(R):Theinformationisorganizedwithonerecordoneachline and
each field is separated by comma.
SECTIONB
19. Rao has written a code to input a number and check whether it is 2
primeornot.Hiscodeishavingerrors. Rewritethecorrectcodeand
underline the corrections made.
defprime():
n=int(input("Enternumbertocheck::") for i in
range (2, n//2):
if n%i=0:
print("Numberisnotprime\n") break
else:
print("Numberisprime\n’)
20. WritetwopointsofdifferencebetweenCircuitSwitchingandPacket 2
Switching.
OR
WritetwopointsofdifferencebetweenXMLand HTML.
Writetheoutputof:print(myexam[::-2])
1
(b) Writetheoutputofthecodegivenbelow:
my_dict={"name":"Aman","age":26}
my_dict['age'] = 27 my_dict['address'] =
"Delhi"print(my_dict.items())
22. Explaintheuseof‘ForeignKey’inaRelationalDatabaseManagement 2
System. Give example to support your answer.
4
23. (a) Writethefullformsofthe following: 2
(i)SMTP (ii)PPP
(b) WhatistheuseofTELNET?
24. PredicttheoutputofthePythoncodegivenbelow: 2
defDiff(N1,N2):
if N1>N2:
returnN1-N2 else:
returnN2-N1
NUM=[10,23,14,54,32]
forCNTinrange(4,0,-1): A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#',end='')
OR
PredicttheoutputofthePythoncodegivenbelow:
tuple1=(11,22,33,44,55,66)
list1=list(tuple1)
new_list = []
foriinlist1: if i
%2==0:
new_list.append(i)
new_tuple=tuple(new_list)
print(new_tuple)
25. Differentiatebetweencount()andcount(*)functionsinSQLwith 2
appropriate example.
OR
CategorizethefollowingcommandsasDDLorDML: INSERT,
UPDATE, ALTER, DROP
SECTIONC
Table:Bank_Account
ACode Name Type
A01 Amrita Savings
A02 Parthodas Current
A03 Miraben Current
5
Table:Branch
ACode City
A01 Delhi
A02 Mumbai
A01 Nagpur
Whatwillbetheoutputofthefollowingstatement?
SELECT*FROMBank_AccountNATURALJOINBranch;
(b) Writetheoutputofthequeries(i)to(iv)basedonthetable,
TECH_COURSE given below:
Table:TECH_COURSE
CID CNAME FEES STARTDATE TID
C201 AnimationandVFX 12000 2022-07-02 101
C202 CADD 15000 2021-11-15 NULL
C203 DCA 10000 2020-10-01 102
C204 DDTP 9000 2021-09-15 104
C205 Mobile Application 18000 2022-11-01 101
Development
C206 Digitalmarketing 16000 2022-07-25 103
(i) SELECTDISTINCTTIDFROMTECH_COURSE;
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM
TECH_COURSEGROUPBYTIDHAVINGCOUNT(TID)>1;
(iii) SELECTCNAMEFROMTECH_COURSEWHERE
FEES>15000 ORDER BY CNAME;
(iv) SELECTAVG(FEES)FROMTECH_COURSEWHERE
FEESBETWEEN15000AND17000;
27. Write a method COUNTLINES() in Python to read lines from text file 3
‘TESTFILE.TXT’anddisplaythelineswhicharenot startingwithany vowel.
Example:
Ifthefilecontentisasfollows:
Anappleadaykeepsthedoctoraway. We
all pray for everyone’s safety.
Amarkeddifferencewillcomeinour country.
TheCOUNTLINES()functionshoulddisplaytheoutputas:
6
Thenumberoflinesnotstartingwithanyvowel-1
OR
Example:
Ifthefilecontentisasfollows:
Todayisapleasantday. It
might rain today.
Itismentionedonweather sites
TheETCount()functionshoulddisplaytheoutputas: E
or e: 6
T or t : 9
Table: Teacher
Table: Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 ComputerSc Nagpur
(i)SELECTDepartment,avg(salary)FROMTeacher GROUP BY
Department;
ii)SELECTMAX(Date_of_Join),MIN(Date_of_Join)FROM Teacher;
ii)SELECTName,Salary,T.Department,PlaceFROM Teacher T,
Placement P WHERE T.Department = P.Department AND
Salary>20000;
iv)SELECTName,PlaceFROMTeacherT,PlacementP
7
WHEREGender=’F’ANDT.Department=P.Department;
(b)Writethecommandtoviewalltablesinadatabase.
29. WriteafunctionINDEX_LIST(L),whereListhelistofelementspassed as 3
argument tothe function. The function returns another list named
‘indexList’ that stores the indices of all Non-Zero Elements of L.
For example:
IfLcontains [12,4,0,11,0,56]
TheindexListwillhave-[0,1,3,5]
30. Alistcontainsfollowingrecordofacustomer: 3
[Customer_name, Phone_number, City]
Writethefollowinguserdefinedfunctionstoperformgivenoperations on
the stack named ‘status’:
(i) Push_element()-ToPushanobjectcontainingname and
PhonenumberofcustomerswholiveinGoatothe stack
(ii) Pop_element() - To Pop the objects from the stack and
displaythem.Also,display“StackEmpty”whenthereareno
elements in the stack.
For example:
Ifthelistsofcustomerdetailsare:
[“Gurdas”,“99999999999”,”Goa”]
[“Julee”,“8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
OR
WriteafunctioninPython, Push(SItem)where,SItemisadictionary
containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who
havepricegreaterthan75.Alsodisplaythecountofelementspushed into
the stack.
For example:
Ifthedictionarycontainsthe following data:
8
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
Thestackshouldcontain
Notebook
Pen
Theoutputshouldbe:
Thecountofelementsinthestackis2
SECTIOND
31. MakeInIndia Corporation, an Uttarakhand based IT training
company,is planning to set up training centres in various cities in
next 2 years. Their first campus is coming up in Kashipur district. At
Kashipur campus, they are planning to have 3 different blocks for
App development, Web designing and Movie editing. Each block
hasnumber of computers, which are required to be connected in a
network for communication, data and resource sharing. As a network
consultant of this company, you have to suggest the best network
relatedsolutionsforthemforissues/problemsraisedinquestionnos.
(i) to (v), keeping in mind the distances between various
blocks/locations and other given parameters.
KASHIPUR
APP CAMPUS
DEVELOPM
MOVIE
ENT EDITING
MUSSOORIE
CAMPUS
WEB
DESIGNING
Block Distance
AppdevelopmenttoWebdesigning 28m
AppdevelopmenttoMovieediting 55m
Web designing to Movie editing 32 m
KashipurCampustoMussoorieCampus 232km
Numberof computers
Block NumberofComputers
App development 75
Webdesigning 50
Movieediting 80
9
toBlock)toeconomicallyconnectvariousblockswithinthe
Kashipur Campus.
(iv) Suggesttheplacementofthefollowingdeviceswithappropriate 1
reasons:
a. Switch/Hub
b. Repeater 1
(v) Suggest a protocol that shall be needed to provide Video
ConferencingsolutionbetweenKashipurCampusandMussoorie
Campus.
p=5
defsum(q,r=2):
global p
p=r+q**2
print(p,end='#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
(b) Thecodegivenbelowinsertsthefollowingrecordinthetable
Student:
RollNo–integer
Name – string
Clas – integer
Marks – integer
NotethefollowingtoestablishconnectivitybetweenPythonand
MYSQL:
Usernameisroot
Passwordistiger
ThetableexistsinaMYSQLdatabasenamedschool.
Thedetails(RollNo,Name,ClasandMarks)areto be
accepted from the user.
Writethefollowingmissingstatementstocompletethecode:
Statement 1 – to form the cursor object
Statement2–toexecutethecommandthatinsertstherecordinthe table
Student.
Statement3-toaddtherecordpermanentlyinthedatabase
importmysql.connectorasmysql def
sql_data():
con1=mysql.connect(host="localhost",user="root",
10
password="tiger",database="school")
mycursor= #Statement1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ") clas=int(input("Enter
class :: ")) marks=int(input("Enter Marks :: "))
querry="insert into student
values({},'{}',{},{})".format(rno,name,clas,marks)
#Statement 2
#Statement3
print("DataAddedsuccessfully")
OR
(a) Predicttheoutputofthecodegivenbelow:
s="welcome2cs"
n=len(s) m=""
foriinrange(0,n):
if(s[i]>='a'ands[i]<='m'): m = m
+s[i].upper()
elif(s[i]>='n'ands[i]<='z'): m = m
+s[i-1]
elif(s[i].isupper()):m=m+s
[i].lower()
else:
m=m+'&'prin
t(m)
(b)Thecodegivenbelowreadsthefollowingrecordfromthetable
named studentand displays only those records who have
marks greater than 75:
RollNo–integer
Name – string
Clas – integer
Marks – integer
NotethefollowingtoestablishconnectivitybetweenPythonand
MYSQL:
Usernameisroot
Passwordistiger
ThetableexistsinaMYSQLdatabasenamedschool.
Writethefollowingmissingstatementstocompletethecode:
Statement 1 – to form the cursor object
Statement2–toexecutethequerythatextractsrecordsofthose students
whose marks are greater than 75.
Statement3-toreadthecompleteresultofthequery(recordswhose
11
12
marksaregreaterthan75)intotheobjectnamed data,fromthe table
studentin the database.
importmysql.connectorasmysql def
sql_data():
con1=mysql.connect(host="localhost",user="root",
password="tiger", database="school")
mycursor= #Statement 1
print("Studentswithmarksgreaterthan75are:
")
#Statement 2
data= #Statement3
for i in data:
print(i)
print()
33. What is the advantage of using a csv file for permanent storage? 5
WriteaPrograminPythonthatdefinesandcallsthefollowinguser
defined functions:
SECTIONE
34. Navdeep creates a table RESULT with a set of records to maintain 1+1+
the marks secured by students in Sem 1, Sem2, Sem3 and their 2
division. After creation of the table, he has entered data of 7
students in the table.
13
103 ISHA 400 410 415 I
Basedonthedatagivenaboveanswerthefollowingquestions:
(i) Identifythemostappropriatecolumn,whichcanbeconsidered as
Primary key.
(ii) Iftwocolumnsareaddedand2rowsaredeletedfromthetable
result, what will be the new degree and cardinality of the
above table?
(iii) Writethestatementsto:
a. Insertthefollowingrecordintothetable
RollNo-108,Name-Aadit,Sem1-470,Sem2-444,Sem3- 475,
Div – I.
b. IncreasetheSEM2marksofthestudentsby3%whose
name begins with ‘N’.
OR(Optionforpartiiionly)
(iii) Writethestatementsto:
a. DeletetherecordofstudentssecuringIVdivision.
b. AddacolumnREMARKSinthetablewithdatatypeas
varcharwith50characters
import #Statement1
defupdate_data(): rec={}
fin=open("record.dat","rb")
fout=open(" ") #Statement2
found=False
eid=int(input("Enteremployeeidtoupdatetheir
14
salary::")) while
True:
try:
rec= #Statement3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enternewsalary
::"))
pickle. #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("Thesalaryofemployeeid",eid,"has been
updated.")
else:
print("Noemployeewithsuchidisnotfound") fin.close()
fout.close()
1
(i) Whichmoduleshouldbeimportedintheprogram?(Statement 1)
(ii) Writethecorrectstatementrequiredtoopenatemporaryfile 1
named temp.dat. (Statement 2)
(iii) WhichstatementshouldAmanfillinStatement3toread the 2
datafromthebinaryfile,record.datandinStatement4to write the
updated data in the file, temp.dat?
15