0% found this document useful (0 votes)
30 views42 pages

Set 1

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)
30 views42 pages

Set 1

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/ 42

Samplequestionpaper-1

Class:XII Session:2023-24computerscience(083)

Time Allowed: 3 Maximum Marks:70


Hours General
Instructions:
• Pleasecheckthisquestionpapercontains35questions.
• Thepaperisdividedinto4Sections- A,B,C,Dande.
• Sectiona,Consists Of 18questions (1to21).Each Questioncarries1mark.
• Sectionb,Consistsof7questions(19to25).Eachquestioncarries2Marks.
• Sectionc,Consistsof 5questions(26to30).Eachquestioncarries3Marks.
• Sectiond,Consistsof2questions(31to32).Eachquestioncarries4Marks.
• Sectione,Consists Of3questions(33to 35).Eachquestioncarries5Marks.
• Allprogrammingquestionsaretobeansweredusingpythonlanguageonly.
Section A
1. Statetrueorfalse:
Doboththefollowingrepresentthesamelist. [1]
['A','B','C']
['C','A','B']

2. Whichoperatorperformspatternmatching? [1]

a) Likeoperator B)Betweenoperator

c) Noneofthese d) Existsoperator

3. Whichofthefollowingiscorrecttoretrieveanycharacteratindex'i'instring's'? [1]

a) S._Getitem_(I B)S.Getitem(I-1)
)
D)S.Getitem(I)
C) S._Getitem_(I-
1)

4. Whatwillbetheoutputofthefollowingcode? [1]
Value=50
Defdisplay(N
):Globalval
ue
Value=25
Ifn%7==0:
Value=Value+N
else:
Value=Value-N
r -------------------------------,
Print(Value,End= )

11#11display(20}
Print(Value)

A)5#50#
B)50#50
C)50#5
D}50#30

5. Signalsgeneratedbyanoperatingsystemtosenditoverphonelinemustbefurther [1]
Converted Intoa/An

a) Analogsignal B)Microwave

C)Acsignal D)Digitalsignal

6. Toreadthenextlineofthefilefromafileobjectinfi,Weuse [1]

a) Infi.Read() B)Infi.Readlines()

C)Infi.Readline() D)Infi.Read(All)

7. Whatis Defaultvalueofhost? [1]

a) Localhost B)Globalhost

C)Host D)Noneofthese

8. Whichofthefollowingsublanguagesofsqlisusedtodefinethestructureofthe [1]
Relation,Deletingrelationsandrelatingschemas?

a) Relationalschema B)DDL(Datadefinitionlanguage)

c) DML(Datamanipulati d) Query
onlanguage)

9. Whichfunctionisusedtoreadallthecharacters? [1]
Page2
L -------------------------------
r -------------------------------,
a) Readcharacters( ) B)Read()

c) Readchar( d) Readall()
)

10. Whatwillbetheoutputofthefollowingpythoncode? [1]

Defadd(Numl,Num2
):Sum=Numl+Nu
m2

Page3
L -------------------------------
r -------------------------------,
Sum=Add(20,30)Prin
t(Sum)

a) None B)Null

C)50 D)O

11. Considerthefollowingoperationperformedonastackofsize5. [1]


Push(L);Pop();Push(2);Push(3);Pop();Push(4);Pop();Pop();Push(5);
Afterthecompletionofalloperation,Thenumberofelementspresent Instackare:

a) 4 B)3

C)1 D)2

12. Whichofthefollowingistheuseoffunctioninpython? [1]

a) Functionsdon'tprovidebetter b) Functionsarereusablepiecesofp
modularityforyourapplicatio rograms
n

c) Youcan'talsocreateyourown d) Allofthese
functions

13. Statetrueorfalse: [1]


Pingchecksifacomputerisconnectedtoanetworkornot.

14. Theprocessofconvertingadatatypeintoanotherdatatypeisknownas . [1]

a) Expression B)Typeconversion

C)Operator D)Comparison

15. Fillintheblanks:
Operator Isusedtomatchavaluesimilartospecificpatterninacolumnusing
Page4
L -------------------------------
r -------------------------------,
d_. [1]
16. Cdmastandsfor?

a) Calldivisionmultipleaccess B)Channeldivisionmultipleaccess
[1]
C)Celldivisionmultipleaccess D)Codedivisionmultipleaccess

Page5
L -------------------------------
r -------------------------------,
17. Assertion(A):Theintersection_Update()Methodisdifferentfromtheintersection() [1]
Method.
Reason(R):Intersection_Update()Methodmodifiestheoriginalsetbyremovingtheunwa
nted Items.

a) Bothaandraretrueandristheco b) Bothaandr Aretruebutr


rrectexplanationofa. Isnotthecorrectexplanationofa.

c) Aistruebutr Isfalse. D)Aisfalsebutristrue.

18. Assertion(A):Csvstandsforcomma-Separatedvalues,Whichisdefinedasasimple [1]


Fileformatthatusesspecificstructuringtoarrangetabulardata.
Reason(R):The Csvmoduleis Usedtohandlethecsvfilestoread/Write
Andgetdatafromspecifiedcolumns.

a) Bothaandraretrue b) Bothaandraretruebutrisnotthec
Andristhecorrectexplanation orrectexplanationofa.
ofa.

c) Aistruebutr Isfalse. D)Aisfalsebutristrue.

Sectionb
19. Answer: [2]
(i)
I.
Whatismodulation? [1]

Ii. Writeonecharacteristiceachfor2Gand3Gmobiletechnologies. [1]

(ii) OR
i. Whatarethebasicmethodsofcheckingerrorsinthedatabeingtra [2]
nsmittedovernetworks?

20. Writepythoncodetocreateatablelocationwiththefollowingfields [2]

Page6
L -------------------------------
r -------------------------------,
Id Idofthelocation
Bidycode Code Ofthebuilding
Room Typeofrooms
Capacity Capacityoftheroom

21. [2]

Rewritethefollowingcodeinpythonafterremovingallsyntaxerror(S)
.Underlineeachcorrectiondoneinthecode.
30=To
Forkinrange(O,To
)Ifk%4==0:
Print(K*4)

Page7
L -------------------------------
r -------------------------------,
Else:
Print(K +3)

OR
Whatistheoutputofthe Following?
True=Falsewhi
letrue:Print(Tr
ue)Break

22. Answer: [2]


(i) Whichcommandisusedtoimportmysql.Connectorpackagewithanidentifier? [1]

(ii) Whatwillthefollowingquerydo? [1]


Importmysql.Connector
Db=Mysql.Connector.Connect(..)Cu
rsor=Db.Cursor()
Person_Id=Input("Enterrequiredpersonid")Lastn
ame=Input("Enterrequiredlastname")
Db.Execute("Insertintostaff(Person_Id,Lastname)VALUES({},'{}')11

Format(Person_Id,
Lastname))Db.Commit()
B.Close()

23. Differentiatebetweenalogicalerrorandsyntaxerror.Also,Givesuitableexamplesof[2]
Eachinpython.

OR
Asimmutabletypescannotbechangedinplacethenthefollowingcodeshouldraiseanerr
orwhichmodifiesanint(Animmutabletype)Variable.Butitproducesnoerror.Why?
A=22
A+=2

24. Considerabinaryfileemployee.Datcontainingdetailssuchasempno:Ename:Salary [2]


(Separator':').Writeapythonfunctiontodisplaydetailsofthoseemployeeswhoareear
Page8
L -------------------------------
r -------------------------------,
ningbetween20000and40000.(Bothvaluesinclusive)

OR
Atextfile(Sayan.Txt)Containsalphanumerictext.Writeaprogramthatreadsthistextfilea
ndprintsonlythenumbersordigitsfromthefile.

25. Writeafunctionthattakesapositiveintegerandreturnstheone'spositiondigitof [2]


Theinteger.

Page9
L -------------------------------
r -------------------------------,

Sectionc

26. Answer: [3]


(i) Writeaprogramwhichwillfindallsuchnumberswhicharedivisibleby7but [1.5]
Arenotamultipleof5,Between200and300(Bothincluded).

(ii) Predicttheoutput. [1.5]

D ie={'A':1,1 :
2,1 3,1 :4}
b1 c1 d1
Print(Die)
If'a'indie:
Deldic[1
]

a1
Print(Die)

27. Writeamethodinpythontofindanddisplaytheprimenumberbetween2ton. [3]


Passnasanargumenttothemethod.

28. Createatablenamedprogrammerswiththefollowingstructure: [3]

PName VARCHAR(20)
DOJ Date
SAL NUMBER

i. Displaythenameoftheprogrammer,Whichhasthehighestsalary.

ii. Updatethesalaryofallprogrammerby2000,Whosenamestartwithletterr.

OR
Whataretuplesinasqltable? Writeasuitableexamplewitha
Sqltabletoillustrateyouranswer.
Page10
L -------------------------------
r -------------------------------,
29. Atextfile 11Quotes.Txt11 [3
Hasthefollowingdatawritteninit:Livingalifeyoucanbep ]
Spendingyourtimewithpeopleandactivitiesthatareimportanttoyoust
anding Upforthingsthatare Rightevenwhenit'shard
Becomingthebestversionofyou
Writeauserdefinedfunctiontodisplaythetotalnumber
Ofwordspresentinthefile.
30. Writeafunctionthattakesasortedlistandanumberasanargument.Searchforthenum [3]
berinthesortedlistusingbinarysearch.

Page11
L -------------------------------
r -------------------------------,

Sectiond
31. .
Ayurvedatrainingeducationalinstituteissettingupitscentreinhyderabadwith [5]
Threespecializeddepartmentsfororthopaedics,Neurologyandpaediatricsalong
withanadministrativeofficeinseparatebuildings.Thephysicaldistancesbetween
thesedepartmentbuildingsandthememberofcomputerstobeinstalledinthese
Departmentsandadministrativeofficesaregivenasfollows.You,Asanetworkex
perthavetheshortestdistancesbetweenvariouslocationsinmeters:
Administrativeofficetoorthopaedicsunit 55
Neurologyunittoadministrativeoffice 30
Orthopedicsunittoneurologyunit 70
Paediatricsunittoneurologyunit 50
Pediatricsunittoadministrativeoffice 40
Paediatricsunittoorthopaedicsunit 110

Thenumberofcomputersinstalledatthevariouslocationisasfollows:

Paediatricsunit 40
Administrativeoffice 140
Neurologyunit 50
Orthopedicsunit 80

IAdministrativeofficeI
IOrthopaedicsunit I
J NeurologyunitJ

i. Suggestthemostsuitablelocationforthemainserverofthis
Institutiontogetefficientconnectivity.
ii. Suggestthecablelayoutforeffectivenetworkconnectivityofthebuildingha
vingaserverwithalltheotherbuildings.
Page12
L -------------------------------
r -------------------------------,
iii. Suggestadevicetobeinstalledineachofthesebuildingforconnectingc
omputersinstalledwithinthebuildingoutofthefollowing:
• Gateway
• Modem
• Switch

Page13
L -------------------------------
r -------------------------------,

iv. Suggestthetopologyofthenetworkandnetworkcableforefficientlyconnecti
ngineachofthebuildingoneofthefollowing:Topologies:Bustopology,Start
opology,Networkcable:Singlepairtelephonecable,Coaxialcable,Ethernetcab
le.

32. . Writesqlqueriesfor(I)To(Vii)Onthebasisoftableitemsandtraders:
[S]
Table:ITEMS

ICODE INAME QTY PRICE COMPANY TCODE


1001 DIGITALPAD12i 120 11000 XENITA Tol
1006 LEDSCREEN40 70 38000 SANTORA T02
1004 CARGPSSYSTEM So 21500 GEOKNOW Tol
1003 DIGITALCAMERA12X 160 8000 DIGICLICK T02
1005 PENDRIVE32GB 600 1200 STOREHOME T03
Table:TRADERS

Tcode Tname City


101 ELECTRONICSALES MUMBAI
103 BUSYSTORECORP DELHI
102 DISPHOUSEINC CHENNAI
i. Todisplaythedetailsofalltheitemsinascendingorderofitemnames(I.E.
,INAME).
ii. Todisplayitemnameandpriceofallthoseitems,Whosepriceisintherangeof10
000and22000(Bothvaluesinclusive).
iii. Todisplaythenumberofitems,Whicharetradedby
Eachtrader.Theexpectedoutputofthisqueryshouldbe:
Tol2t022t031
iv. Todisplaytheprice,Itemnameandquantity(I.E.,Qty)Ofthoseitemswhichh
avequantitymorethan150.
v. Todisplaythenamesof Thosetraders,Whoareeitherfromdelhior
Frommumbai.
vi. Todisplaythenamesofthecompaniesandthenamesoftheitemsindescendin
Page14
L -------------------------------
r -------------------------------,
gorderofcompanynames.

Page15
L -------------------------------
r -------------------------------,

vii. Obtaintheoutputsofthefollowingsqlqueriesbasedonthedatagivenintablesitem
sandtradersabove.
a. SELECTMAX(PRICE),MIN(PRICE)FROMITEMS;

b. SELECTPRICE*QTYFROMITEMSWHERECODE=1004;

c. SELECTDISTINCTTCODEFROMITEMS;

d. SELECTINAME,TNAMEFROMITEMSI,Traderstwherel.TCODE=T.TCOD
EANDQTY<Loo;

OR
Considerthefollowingtablesworkerandpaylevelandanswer(A)And(B)Partsofthisqu
estion:
Table:WORKER

ECODE NAME DESIGN PLEVE DOJ DOB


11 Radheshyam Supervisor L
Pool 13-Sep-2004 23-Aug-1981
12 Chandernath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-Jun-2009 14-0ct-1983
15 Ameenahmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
Table:PAYLEVEL

PLEVEL PAY ALLOWANCE


Pool 26000 12000
P002 22000 10000
P003 12000 6000
a. Writesqlcommandsforthefollowingstatements:

i. Todisplaythenameofallworkersindescendingorderofdob.

ii. Todisplaynameanddesignofthoseworkers,Whose
Pleveliseitherpoolorp002.

Page16
L -------------------------------
R-------------------------------,

iii. Todisplaythecontentofalltheworkerstable,Whosedobisinbetween'19-
JAN-1984'and'18-JAN-1987'.
iv. Toaddanewrowwiththefollowing:19,'Dayakishore','Operator','P003','1
9-Sep-2008', 17-Jul-1984'
b. Givetheoutputofthefollowingsqlqueries:
i. SELECTCOUNT(PLEVEL),PLEVELFROMWORKERGROUP
BYPLEVEL;Ii.SELECTMAX(DOB),MIN(DOJ)FROMWORKER;
iii. Selectname,PAYFROMWORKERW,PAYLEVELPWHEREW.PLEVEL=P.
PLEVELANDW.ECODE<13;

iv. SELECTPLEVEL,PAY+ALLOWANCEFROMPAYLEVELWHEREPLEVEL="P003
1
1
;

33. Answer: [S]


(i)
I. Whatistheuseofwhereclauseinsql?
[1]

ii. Answerthequestions(I)To (V)Onthebasisofthefollowingtablesshoppe

[4]Andaccessories.
TABLE:SHOPPE

Id Sname Area
Sool Abccomputeronics CP
S002 Alllnfotechmedia Gkll
S003 Techshoppe CP
S004 Geekstecnosoft Nehruplace
SOOS Hitechtechstore Nehruplace
TABLE:ACCESSORIES

No Name Price Id
Aol Motherboard 12000 Sol
A02 Harddisk 5000 Sol

L ------------------------------- Page1O
r -------------------------------,

A03 Keyboard Soo S02


A04 Mouse 300 Sol
AOS Motherboard 13000 S02
A06 Keyboard 400 S03
A07 LCD 6000 S04
T08 LCD Ssoo Sos
T09 Mouse 3SO Sos
Tlo Harddisk 4SOO S03
i. Todisplaynameandpriceofalltheaccessoriesinascendingorderofth
eirprice.
ii. Todisplayidandsnameofallshoppelocatedinnehruplace.
iii. Todisplayminimumandmaximumpriceofeachnameofaccessories.
iv. Todisplayname,
Priceofallaccessoriesandtheirrespectivesname,Wheretheyareava
ilable.
v. Todisplaynameofaccessorieswhoseprice Isgreaterthan1000.

(Ii) OR
I. Givethesyntaxofdropstatement. [1
]
Ii. Considerthefollowingtablestore.Writesqlcommandsforthefollowingst [4]
atements.
Table:STORE

Itemno Item Scode Qty Rate Lastbuy


Sharpener
200S classic 23 60 8 31-Jun-09
2003 Ballpen0.2S 22 So 2S 01-Feb-10
Gelpen
2002 premiu 21 L SO 12 24-Feb-10
Gelpen
2006 classic 21 2SO 20 11-Mar-
2001 Erasersmall 22 220 6 09
19-Jan-09
2004 Eraserbig 22 110 8 02-Dec-09
Page11
L -------------------------------
r -------------------------------,
2009 Ballpeno.S 21 180 18 03-Nov-09
i. Todisplaydetailsofalltheitemsinthestoretableinascendingorderof
lastbuy.

Page12
L -------------------------------
r -------------------------------,
ii. Todisplayitemnoanditemnameofthoseitemsfromstoretablewhose
rateismorethan15rupees.
iii. Todisplaythedetailsofthoseitemswhosesupplierscode(Scode)Is
22orquantityinstore(Qty)Ismorethan110fromthetablestore.
iv. Todisplaytheminimumrateofitemsforeachsupplierindividually
asperscodefromthetablestore.

Sectione
34. Writeaprogramtoperformbinarysearchonalistofstringsarrangedindescending [4]
Order.

35. . Writesqlcommandsfor(I)To(V)Onthebasisoftableemployee [4]


TABLE: EMPLOYEE

SNO NAME BASIC DEPARTMEN DATOFAPP AGE SEX


1 KARAN 8000 TPERSONNEL 27/03/97 35 M
2 DIVAKA 9500 COMPUTER 20/01/98 34 M
3 RDIVYA 7300 ACCOUNTS 19/02/97 34 F
4 ARUN 8350 PERSONNEL 01/01/95 33 M
5 SABINA 9500 ACCOUNTS 12/01/96 36 F
6 JOHN 7400 FINANCE 24/02/97 36 M
7 ROBERT 8250 PERSONNEL 20/02/97 39 M
8 RUBINA 9450 MAINTENANC 22/02/98 37 F
9 VIKAS 7500 E COMPUTER 13/01/94 41 M
10 MOHAN 9300 MAINTENANC 19/02/98 37 M
E
i. Whichcommandwillbeusedtolist
Thenamesoftheemployees,Whoaremorethan34yearsoldsortedbyname.
a. SELECTNAMEFROMEMPLOYEEWHEREAGE>34ORDERBYNAME;

b. SELECT*FROMEMPLOYEEWHEREAGE>34ORDERBYNAME;

c. SELECTNAMEFROMEMPLOYEEWHEREAGE>34;

d. SELECTNAMEFROMEMPLOYEEAGE>34ORDERBYNAME;

Page13
L -------------------------------
R-------------------------------,

ii. Writeaquerytodisplayareport,Listingname,BASIC,Departmentandannualsa
lary.Annualsalaryequalstobasic*12.
iii. Insertthefollowingdataintheemployeetable
11,'VIJAY',9300,'FINANCE','13/7/98',35
,"M"
iv. Writeaquerytocountthenumberofemployees,Whoareeitherworkinginpe
rsonnelorcomputerdepartment.
v. Writethedegreeandcardinalityofthetableemployee.
L ------------------------------- Page13
r -------------------------------,

Solutions

Sectiona

1.
(B)False
Explanation:False
Thelistsareordered.
2. (A)Likeoperator
Explanation:Likeoperatorisusedinthewhereclauseallowsusasearchbasedoperationonapat
tern.
3. (A) S._Getitem_(I)
Explanation:Itisthecorrectsyntaxtocallcharacteratindexiofstrings
4.
(C)50#5
Explanation:50#5
5.(A)Analogsignal
Explanation:Ananalogsignalisany Continuoussignalforwhichthetime-
Varyingfeatureofthesignalisarepresentationofsomeothertime-
Varyingquantity,I.E.,Analogoustoanothertime-
Varyingsignal.Analogsignalsproducetoomuch
Noise. Examples:-Humanvoice,Thermometer,Analogphones,Etc.
6.
(C)Infi.Readline()
Explanation:Readline()Functionreadsalinefromthefilepointerposition.
7.(A)Localhost
Explanation: Localhost
8.
(B)DDL(Datadefinitionlanguage)
Explanation:DDL(Datadefinitionlanguage)Isthelanguagewhichperformsalltheoperation
indefiningstructureofrelation.
9.
(B)Read()
Explanation:Read()Functionreadsthewholefileandreturnsthe Textasastring.
10.(A)None

L -------------------------------
r -------------------------------,
Explanation:None
11.
(C)1
Explanation:1
12.
(B)Functionsarereusablepiecesofprograms
Explanation:Functionsarereusablepiecesof Programs.Theyallowyoutogiveaname
Page14

L -------------------------------
r -------------------------------,
Toablockofstatements,Allowingyoutorunthatblockusingthespecifiednameanywhereinyou
rprogramandanynumberoftimes.
13.(A)True
Explanation:True
14.
(B)Typeconversion
Explanation:Typeconversion
15.1.LIKE
16.
(D)Codedivisionmultipleaccess
Explanation:Cdmastandsforcodedivisionmultipleaccess.Inthis,Eachuserisallocatedauni
quecodesequence,Thatisusedtoencode/Decodetheoriginaldata.
17.(A)Bothaandraretrueandristhecorrectexplanationofa.
Explanation:Theintersection_Update()Methodisdifferentfromtheintersection()Method
since Itmodifiestheoriginalsetbyremovingthe
Unwanteditems,Ontheotherhand,Theintersection()Methodreturnsanewset
Removingtheunwanteditems.
18.
(B)Bothaandraretruebutrisnotthecorrectexplanationofa.
Explanation:Csvstandsfor"Comma-
Separatedvalues",Whichisdefinedasasimplefileformatthatusesspecificstructuringtoarran
getabulardata.Itstorestabulardatasuchas
Spreadsheetsordatabasesinplaintextandhasacommonformatfordata
Interchange.Inpython,Thecsvmoduleisusedtohandlethecsvfilestoread/
Writeandgetdatafromspecifiedcolumns.
Section B
19. Answer:
(i) I.Theprocessofalteringthecharacteristics(Amplitudeorfrequencyetc.)Ofahigh-
Frequencywavecalledthecarrierwavesothatitcancarrylow-
Frequencyinformationalongwithitwhilebeingtransmitted,Iscalledmodulation.
Ii.2Gnetworksprimarilyinvolvethetransmissionofvoiceinformationwhile3Gtechn
ologyprovidestheadditionaladvantageofdatatransfer.
(ii) OR
i. Therearemanymethodsofcheckingordetectingerrorsinthedatatransmitted.Thef
oursimplestonesare:
i. Singledimensionalparitychecking
ii. Two-Dimensional Paritychecking
Page15
L -------------------------------
r -------------------------------,
iii. Checksum
iv. Cyclicredundancycheck(CRC)

20. Importmysqldb
Db=Mysqldb.Connect("Localhost", )

"Admin","Ad123",11HMD11cursor=Db.Cursor()

Page16
L -------------------------------
r -------------------------------,
Cursor.Execute("Droptableifexistslocation")

Sql="11 "Createtablelocation(Idnumeric(S)PRIMARYKEY,Bidycodevarchar(Lo)
Notnull,
Roomvarchar(G)Notnull,Capacitynumeric(S)Notnull)"11 11
Cursor.Execute(Sql)Db.Cl
ose()
21. To=30#Variablenameshouldbeonlhsforki
nrange(O,To)_;_#:Wasmissing
Ifk%4==0:#Ifshouldbein Lowercase;I.E;If
Print(K*4)
Else:#Else
Shouldbeinlowercaseprint(K+3)
OR
Theabovecodewillgiveerrorbecausekeywordtruehasbeenusedasvariable(Infirstlineofc
odetrue=False).Wecannotusekeywordsasvariablesoranyotheridentifiers.
22. Answer:
(i) Importmysql.Connector
Asidentifier_Namee.G.
Importmysql.Connectorasmydb
(ii) Itwilladdanewrecordinthedatabaseafterobtainingvaluesofperson-Id,And
Lastnamefromuser.

23. Differencesbetweenlogicalerrorandsyntaxerrorareasfollows:
Logicalerror Syntaxerror
Itoccurswhenstatementsarewrongly
Itoccursbecauseofwrongimplementation writtenviolatingrules
Oflogic. Oftheprogramminglanguage.
Withlogicalerrors,Thecodeissyntacticallyc Withsyntaxerrors,Thecodeisnotsyntac
orrectandcompilerwillnotshowanyerrormes ticallycorrectandcompilerwillshowthe
sage. errormessages.
Itproducestheoutput,Butundesired. Itdoesnotproduceanyoutput.
E.G.Inplaceof(C=A*B);Ifbymistake(C=A E.G.Inplaceof(A==B);Ifbymistake(A==
+B);Iswritten,Itwillbealogicalerror. B);Iswritten,Itwillbeasyntaxerror.
OR
Inthegivencode,Aisaninttypevariable,Whichisanimmutabletype,Whichmeansitsvalu
Page17
L -------------------------------
r -------------------------------,
ecannotchangeinplace(I.E.,Inthesamememorylocation).So,Whenthesecondstatement
getsexecuted,Thevariable
Nolongerpointstothesamememoryasitwasinstatement1.Sointernallyitismadetopointto
a Newlocationwhichstoresitsvalue
24. So,Inawayanewaiscreatedafterstatement2.

Page18
L -------------------------------
r -------------------------------,
Thus,Whenwemakechangesinanimmutabletypevariable,Internallypythoncreatesane
wvariablehavingthenewvalueandhencenoerrorisreported.Changeofthevaluedoesnott
akeplaceinthesamememorylocationforanimmutabletype.

24. Defreadfile():
I=Open("Employee.Dat",
"Rb+")X=I.Readline()
While(X):L=X.Sp
lit(':')
If (20000>=Float(1[2])<=40000}:
Print(X)X=I.Readl
ine()

OR
Fileobject=Open("An.Txt","R
")Forlineinfileobject:
Words=Line.Spli
t()Forwordinwor
ds:Forcharinwor
d:
If(Char.Isdigit()):Print(C
har)
25. Defget_Ones_Digit(Num):#Returntheonesdigitoftheintegernumo
nes_Digit=Num%10
Returnones_Digit
Get_Ones_Digitfunctionreturnsthedigitatone'spositionofnumbernum.
Sectionc
26. Answer:

(i) I=[]
Foriinrange(200,300}:If(I
%7==0}And(I%5!=0}
I.Append(Str(I)
)Print(','.Join(I))

(ii) Output
{'D':4,'A':1,'C':3,'B':2}
Page17
L -------------------------------
r -------------------------------,
{'D':4,'C':3,'B':2}

27. Defprime(N):
Fornuminrange(2,N):Is
_Prime=1
Foriinrange(2,Num):

Page18
L -------------------------------
r -------------------------------,
Ifnum
%I==0:Is_Prime=0
Ifis_Prime==1:Pri
nt(Num)
28. I.SELECTP_Namemax(SAL)
Fromprogrammers;
i. Updateprogrammerssetsal=SAL+2000WHEREP_Name LIKE R%
1 1 ;

OR
Indbms,Thisroworrecordisknownasatuple.Henceindbms,Atupleisjustarowrepresentings
omeassociateddataforacertainentity,Suchasauser,Student,Oremployee.Youcanseefromth
efigureabovethatatupleisarow
Ofinformationaboutasingleitem,Suchasitsname,Age,Marks,Etc.
29.Userdefinefunctiontodisplaytotalnumberofwordsinafile:
Defcountwords():

S=Open(11Quotes.Tx 1r 1
,

)
t11
F=S,Read(
)
Z=F.Split(
)Count=O
Foriinz:Count
=Count+L
Print( 11Totalnumberofwords",Count)
30. Defbinary_Search(Sorted_List,
Number):Low=O
High=Len(Sorted_List)F
ound=False
While(Low<High)Andfound=False:
Mid=Int(Low+High/2)
Ifsorted_List[Mid]==Numbe
r:Print
("Numberfoundat 11,Mid)Fo
und=True
Break
Elifsorted_List[Mid]==Number:
Page19
L -------------------------------
r -------------------------------,
Low=Mid+1
Else:
High=Mid-
1iflow>=Hig
h:
Print("Numbernotfound")

Max_Range=Input(11entercountofnumbers:")Numlis
t=[]
Foriinrange(O,Max_Range):

Numlist_Append(Input(11Enternumber:11
}}

Page20
L -------------------------------
r -------------------------------,
Numlist.Sort()P
Numlist)
rint(110urlist:1
,

Number=Input(11Enterthenumber11
)

Binary_Search(Numlist, Number)

Section D
31. I.Administrativeofficeisthemostsuitablelocationforthemainserverofthisinsti
tutiontogetefficientconnectivity.

ii. Switchtobeinstalledineachofthesebuildingforconnectingcomputersinstalledwithint
he Building
iii. Topology:Startopology
Networkcableethernetcable/Coaxialcable
32. I.SELECT*FROMITEMSORDERBYINAMEASC;
ii. SELECTINAME,PRICEFROMITEMSWHERE PRICE=>10000ANDPRICE=<22000;
iii. SELECTTCODE, COUNT(CODE)FROM ITEMSGROUPBYTCODE;
iv. SELECTPRICE,INAME,QTYFROMITEMSWHEREQTY>150;
11delhl1
v. SELECTTNAMEFROMTRADERSWHERE(CITY= OR(CITY=11mumbal11
)

1
)

vi. SELECTCOMPANY,INAMEFROM ITEMSORDERBYCOMPANYDESC;


vii. A.38000
1200
B.1075000
c. T03
d. LEDSCREEN40DISPHOUSEINCCARGPSSYSTEMELECTRONICSsales
OR
a. I.SELECTNAMEFROMWORKERORDERBYDOBDESC;

Ii.SELECTNAME,DESIGNFROMWORKERWHEREPLEVEL=11pool11 ORPLEVEL=
Page21
L -------------------------------
r -------------------------------,
11Poo211
;OR
SELECTNAME,DESIGNFROMWORKERWHEREPLEVELIN('Pool','P002');

Page22
L -------------------------------
r -------------------------------,

iii. SELECT*FROMWORKERWHEREDOBBETWEEN 1 19-JAN-


19841AND1 18-JAN- 19871; , ,

iv. INSERTINTOWORKERVALUES(19,11dayakish 110perator 11P003 1 19-Sep-


,

ore 11 11 11
20081,17-Jul-1984');

B.I. count(PLEVEL) PLEVEL


1 POOl

2 P002

2 P003

Max(DOB) Min(DOJ)
12-Jul-1987 13-Sep-2004

Name Pay
Ii.
RadheShyam 26000

ChanderNath 12000

PleveI Pay
Iii.
P003 18000

Iv.

33.Answer:
(i) I.Thewhereclause Isusedtoextractonlythoserecordsthatfulfila
Specifiedcriteria.

ii. I.Selectname,Pricefro
Page20
L -------------------------------
r -------------------------------,
maccessoriesorderby
price;

ii. Selectid,Snamefr
omshoppe
Wherearea='Nehruplace';

iii. SELECTMIN(Price)"Minimumprice",MAX(Price)"Maximumprice",Na
mefromaccessories
Groupbyname;

Page20
L -------------------------------
r -------------------------------,

iv. Selectname,Price,Snamefromacce
ssoriesa,SHOPPESWHEREA.Id=
S.Ld;

Butthisqueryenabletoshowtheresultbecausea.Idands.Ldarenotidentical.

v. Selectnamefromaccessorieswhere
price>Looo;

(ii) OR
i. Droptabletable_Name;
ii. I.SELECT*
FROMSTORE
Orderbylastbuy;
ii. Selectltemno,Itemfro
mstore
Whererate>15;
iii. SELECT*FR
OMSTORE
Wherescode=22orqty >110;
iv. Selectscode,Min(Rate)F
ROMSTORE
Groupbyscode;

r:Beg=Mid+L
Else:Last=Mid-1else:
34. Defbsearch(Strarr,St
Returnfalse
r):Beg=O
Last=Len(Strar ---Main---
r)-
1while(Beg<=L
ast):Mid=(Beg
+Last)/2
Ifstrarr[Mid]==Str:
Returnmid
Elifstrarr[Mid]>=St

Page21
L -------------------------------
r -------------------------------,
Sectione
N=Int(Raw_Input("Enter
No.Ofelementsofthearray".)Print(''\
Nenterstringsindescendingorder:")
Ar=[""]*N

Page21
L -------------------------------
R-------------------------------,

Foriinrange(N):
Ar[I]Raw_Input("String"+I+":")
Item=Raw_Input("Enterstringtobesearched:")F
oundat=Bsearch(Ar,Item)
Iffoundat:
Print''\
Nelementfoundat",Foundatelse:
Print11\Nstringnetfount"

35. I.(A)SELECTNAMEFROMEMPLOYEEWHEREAGE>34ORDERBYNAME;
ii. SELECTNAME,BASIC,DEPARTMENT,BASIC*12"Annualsalary"FROMEMPLOYEE;
INSERTINTOEMPLOYEEVALUES{L,'VIJAY',9300,'FINANCE','13/7
iii.
/98',35,'M');Iv.SELECTCOUNT(*)FROMEMPLOYEE
WHERE DEPARTMENT='PERSONNEL' OR DEPARTMENT='COMPUTER';
V.Degreeofthegiventableis7 Andcardinalityis10.
L ------------------------------- Page22

You might also like