0% found this document useful (0 votes)
39 views15 pages

ComputerScience-SQP) 2024 Preboard

Uploaded by

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

ComputerScience-SQP) 2024 Preboard

Uploaded by

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

Class:XIISession:2024-25

Computer Science (083)


SampleQuestionPaper(Theory)
Maximum Marks: 70 TimeAllowed:3hours
General Instructions:

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.”

2. Which of the following is an invalid data type in Python? 1


(a)Set (b) None (c)Integer (d)Real

3. Given the following dictionaries 1

dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500,"Pass_Marks":165}

Which statement will merge the contents of both dictionaries?


a. dict_exam.update(dict_result)
b. dict_exam+dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)

4. Consider the given expression: 1


Not True and False or True
Which of the following will be correct outputifthegivenexpressionis
evaluated?

(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)

(a) Year.0.at Allthe best


(b) Year0.atAllthe best
(c) Year.022.atAllthebest
(d) Year.0.atallthe best

6. Whichofthefollowingmodeinfileopeningstatementresultsor generates 1
an error if the file does not exist?

(a)a+ (b)r+ (c)w+ (d)Noneoftheabove

7. Fillintheblank: 1

commandisusedtoremoveprimarykeyfromthetableinSQL.

(a)update (b)remove (c) alter (d)drop

8. Whichofthefollowingcommandswilldeletethe tablefromMYSQL 1
database?
(a) DELETETABLE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE

9. Whichofthefollowingstatement(s)wouldgiveanerrorafter 1
executing the following code?

S="Welcome to class XII" #Statement1


print(S) #Statement2
S="Thankyou" #Statement3
S[0]='@' #Statement4
S=S+"Thankyou" #Statement5

(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.

(a)VoIP (b) SMTP (c)PPP (d)HTTP

14. WhatwillthefollowingexpressionbeevaluatedtoinPython? 1
print(15.0/4+(8+ 3.0))

(a)14.75 (b)14.0 (c)15 (d)15.5

15. Whichfunctionisusedtodisplaythetotalnumberofrecordsfrom table in 1


a database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)

16. To establish a connection between Python and SQL database, 1


connect()isused.Whichofthefollowingargumentsmaynot necessarily
be given while calling connect()?

(a) host
(b) database
(c) user
(d) password

Q17and18areASSERTIONANDREASONINGbasedquestions. Markthecorrect choice


as
(a)BothAandRaretrueandRisthecorrectexplanationforA

3
(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTrue butRisFalse
(d) AisfalsebutRisTrue

17. Assertion(A):-Iftheargumentsin functioncallstatementmatchthe 1


numberandorderofargumentsasdefinedinthefunctiondefinition,
such arguments are called positional arguments.
Reasoning(R):-Duringafunctioncall,theargumentlistfirstcontains
default argument(s) followed by positional argument(s).

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.

21. (a) GivenisaPythonstringdeclaration: 1


myexam="@@CBSEExamination2022@@"

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

26. (a)Considerthefollowingtables –Bank_AccountandBranch: 1+2

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

Write a function ETCount() in Python, which should read each


characterofatextfile“TESTFILE.TXT”andthencountanddisplay
thecountofoccurrenceofalphabetsEandTindividually(including small
cases e and t too).

Example:

Ifthefilecontentisasfollows:

Todayisapleasantday. It
might rain today.
Itismentionedonweather sites

TheETCount()functionshoulddisplaytheoutputas: E
or e: 6
T or t : 9

28. (a) WritetheoutputsoftheSQLqueries(i)to(iv)basedonthe 3


relations Teacher and Placement given below:

Table: Teacher

T_ID Name Age Department Date_of_join Salary Gender


1 Arunan 34 ComputerSc 2019-01-10 12000 M
2 Saman 31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4 Samira 35 History 2018-07-01 40000 F
5 Raman 42 Mathematics 2021-09-05 25000 M
6 Shyam 50 History 2019-06-27 30000 M
7 Shiv 44 ComputerSc 2019-02-25 21000 M
8 Shalakha 33 Mathematics 2018-07-31 20000 F

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”]

The stack should contain


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
StackEmpty

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

Distancebetween various blocks/locations:

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

(i) Suggest the most appropriate block/location to house the 1


SERVERintheKashipurcampus(outofthe3blocks)togetthe best
and effective connectivity. Justify your answer.
(ii) Suggestadevice/softwaretobeinstalledintheKashipur 1
Campus to take care of data security.
(iii) Suggestthebestwiredmediumanddrawthecablelayout(Block 1

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.

32. (a) Writetheoutputofthecodegivenbelow: 2+3

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:

(i) ADD() – To accept and add data of an employee to a CSV file


‘record.csv’. Each record consists of a list with field elements
asempid,nameandmobiletostoreemployeeid,employee name
and employee salary respectively.
(ii) COUNTR()–TocountthenumberofrecordspresentintheCSV file
named ‘record.csv’.
OR

Giveanyonepointofdifferencebetweenabinary fileandacsvfile. Write a


Program in Python that defines and calls the following user defined
functions:

(i) add() – To accept and add data of an employee to a


CSV file ‘furdata.csv’. Each record consistsof a list with
field elementsasfid,fnameandfpricetostorefurniture
id, furniture name and furniture price respectively.
(ii) search()-Todisplaytherecordsofthefurniturewhose
price is more than 10000.

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.

ROLL_N SNAME SEM SEM2 SEM DIVISION


O 1 3
101 KARAN 366 410 402 I

102 NAMAN 300 350 325 I

13
103 ISHA 400 410 415 I

104 RENU 350 357 415 I

105 ARPIT 100 75 178 IV

106 SABINA 100 205 217 II

107 NEELAM 470 450 471 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

35. Aman is a Python programmer. He has written a code and created a


binaryfilerecord.datwithemployeeid,enameandsalary.Thefile
contains 10 records.
Henowhastoupdatearecordbasedontheemployeeidenteredby the
user and update the salary. The updated record is then to be written
in the file temp.dat. The records which are not to be updated also
have to be written to the file temp.dat. If the employee id is not
found, an appropriate message should to be displayed.
AsaPythonexpert,helphimtocompletethefollowingcodebasedon the
requirement given above:

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

You might also like