FULL PORTIONS 1 ANSWER KEY Ekbs
FULL PORTIONS 1 ANSWER KEY Ekbs
SCHOOL
MARAIYUR ROAD, SITHARKADU, MAYILADUTHURAI – 609003.
General Instructions:
● Thisquestionpapercontains37questions.
● Allquestionsarecompulsory.However,internalchoiceshavebeenprovidedinsome questions.
Attempt only one of the choices in such questions
● Thepaperisdividedinto5Sections-A,B,C,DandE.
● SectionAconsistsof21questions(1to21).Eachquestioncarries1Mark.
● SectionBconsistsof7questions(22to28).Eachquestioncarries2Marks.
● SectionCconsistsof3questions(29to31).Eachquestioncarries3Marks.
● SectionDconsistsof4questions(32to35).Eachquestioncarries4Marks.
● SectionEconsistsof2questions(36to37).Eachquestioncarries5Marks.
● AllprogrammingquestionsaretobeansweredusingPythonLanguageonly.
● IncaseofMCQ,textofthecorrectanswershouldalsobewritten(Nomarksshouldbe
provided if student does not write the correct choice )
1. StateTrueor False:
(1)
ThePythonstatementprint(‘Alpha’+1)isexampleofTypeErrorError
Ans:True
2. Whatidtheoutputoffollowingcodesnippet?
Ans:A)GL-BALNETW-RK
Page:1/22
3. Identifytheoutputofthefollowingcodesnippet:
text="The_quick_brown_fox"
index = text.find("quick")
(1)
result=text[:index].replace("_","")+text[index:].upper()
print(result)
(A) Thequick_brown_fox
(B) TheQUICK_BROWN_FOX
(C) TheQUICKBROWNFOX
(D) TheQUICKBROWN_FOX
Ans:(B)TheQUICK_BROWN_FOX
WhatwillbetheoutputofthefollowingPython expression? x = 5
4.
y= 10
result=(x**2+y)//x*y-x print(result) (1)
(A) 0
(B) -5
(C) 65
(D) 265
Ans: (C)65
Whatwillbetheoutputofthefollowingcodesnippet?
5.
(1)
text="PythonProgramming" print(text[1
: :3])
(A) Phoai
(B) yoPgmn
(C) yhnPormig
(D) Ptorgamn
Ans:(B)
6. Whatwillbetheoutputofthefollowingcode?
tuple1 = (1, 2, 3)
tuple2=tuple1+(4,)
tuple1 += (5,)
print(tuple1, tuple2) (1)
(A) (1,2,3)(1,2,3,4)
(B) (1,2,3,5)(1,2, 3)
(C) (1,2,3,5)(1,2,3,4)
(D) Error
Ans:C)
Page:2/22
7. Dictionarymy_dictasdefinedbelow,identifytypeoferrorraisedby statement
my_dict['grape']?
my_dict={'apple':10,'banana':20,'orange':30}
ValueError (1)
(B) TypeError
(C) KeyError
(D) ValueError
Ans:(C) KeyError
8. Whatdoesthelist.pop(x)methoddoinPython?
A. Removesthefirstelementfromthelist. (1)
B. Removestheelementatindexxfromthelistandreturnsit.
C. Addsanewelementat indexxinthe list.
D. ReplacestheelementatindexxwithNone.
Ans:B.Removestheelementatindexxfromthelistandreturns it.
In a relational database table with one primary key and three unique
9. constraintsdefinedondifferentcolumns(notprimary),howmanycandidate keys
can be derived from this configuration?
(1)
(A)1
(B)3
(C)4
(D)2
Ans:C)4
10. Fillintheblankstocompletethefollowingcodesnippetchoosingthe correct
option:
withopen("sample.txt","w+")asfile:
(1)
file.write("Hello, World!")# Write a string to the file
position_after_write = file. #Getthepositionafterwriting
file.seek(0)# Move the pointer to the beginning
content=file.read(5)#Readthefirst5characters print(content)
(A) tell
(B) seek
(C)read
(D)write
Ans:(A)tell
Page:3/22
11. StatewhetherthefollowingstatementisTrueorFalse:
In Python, if an exception is raised inside a try block and not handled,
theprogramwillterminatewithoutexecutinganyremainingcodeinthe finally (1)
block.
Ans:False
Page:4/22
12. Whatwillbetheoutputofthefollowingcode? x =
4
def reset():
globalx
x=2
print(x,end='&')
def update(): (1)
x+=3
print(x,end='@')
update()
x=6
reset()
print(x,end='$')
(A) 7@2&6$
(B) 7@6&6$
(C) 7@2&2$
(D) Error
Ans:(D)Error:Unboundlocalvariablexinfunction update()
WhichSQLcommandcanmodifythestructureofanexistingtable,suchas adding
13. or removing columns? (1)
(A) ALTERTABLE
(B) UPDATETABLE
(C) MODIFYTABLE
(D) CHANGETABLE
Ans.(A)ALTERTABLE
14. Whatwillbetheoutputofthe query?
SELECT*FROMordersWHEREorder_dateLIKE'2024- 10-%';
(A) DetailsofallordersplacedinOctober2024
(B) DetailsofallordersplacedonOctober10th,2024 (1)
(C) Detailsofallordersplacedintheyear2024
(D) Detailsofallordersplacedonanydayin2024
Ans:(A)DetailsofallordersplacedinOctober2024
WhichofthefollowingstatementsabouttheCHARandVARCHAR datatypes
15.
in SQL is false?
(A) CHARisafixed-lengthdatatype,anditpadsextraspacestomatchthe
specified length. (1)
(B) VARCHARisavariable-lengthdatatypeanddoesnotpadextraspaces.
(C) ThemaximumlengthofaVARCHARcolumnisalwayslessthanthatof a
CHAR column.
(D) CHARisgenerallyusedforstoringdataofaknown,fixedlength.
Ans: (C)
Page:5/22
16. Whichofthefollowingaggregatefunctionscanbeemployedtodetermine the
number of unique entries in a specific column, effectively ignoring
duplicates?
(1)
(A) SUM()
(B) COUNT()
(C) AVG()
(D) COUNT(DISTINCTcolumn_name)
Ans:(D)COUNT(DISTINCTcolumn_name)
Ans: CircuitSwitching
Q20andQ21areAssertion(A)andReason(R)basedquestions.Mark the
correct choice as:
(A) Both AandRare trueandRisthecorrectexplanationfor A
(B) BothAandRaretrueandRisnotthecorrectexplanation for A
(C) AisTruebutRisFalse
(D) AisFalse butRisTrue
Assertion(A):Pythonfunctionscanacceptpositional,keyword,anddefault
20. parameters.
Reasoning(R):Defaultparametersallowfunctionargumentstobeassigned a (1)
default value if no argument is provided during the function call.
Ans : (B) Both Aand R are true and R is not the correct explanantion
for A
Assertion(A):AGROUPBYclauseinSQLcanbeusedwithoutany aggregate
21.
functions.
Reasoning(R):TheGROUPBYclauseisusedtogrouprowsthathavethe (1)
samevaluesinspecifiedcolumnsandmustalwaysbepaired with
aggregate functions.
Page:6/22
Ans:(C )Ais True ,butR is False
Ans:a)aisamutableobject(alist),meaningitscontentscanbe
changed after it is created. This is demonstrated bythe append()
method that adds an element to the list.
c is an immutable object (a tuple). Once created, its contents cannot
bechanged.Theoperationc+(8,)doesnotmodifycbutcreatesanew tuple.
(1 marks+ 1Marks)
Giveexamplesforeachofthefollowingtypesof operatorsinPython:
23.
(2)
(I)AssignmentOperators
(II)Identity Operators
Ans:
1. Example1:=(SimpleAssignment)Usage:x=5(assignsthe value
5to x)
2. Example2:+=(AddandAssign) :Usage:x+=3(equivalenttox
=x+3)
Page:7/22
IfL1=[10,20,30,40,20,10,...] andL2=[5,15,25,...], then:
24.
(Answerusingbuiltinfunctionsonly)
(II) A)WriteastatementtoextendL1withallelementsfromL2.
OR
B)Writeastatementtogetanewlistthatcontainstheuniqueelements from L1.
Ans:I( A):count_20=L1.count(20)
(B): min_value=min(L1)
II(A): L1.extend(L2)
(B):unique_elements=list(set(L1))
(A)A* (B)A*D*
(C)A*d*v* (D)A*d*v*e*n*t*u*
Ans: Minimumpossiblevalueof b:1( 1/2+1/2marks)
Maximumpossiblevalueofb:5
Page:8/22
26. The code provided below is intended to reverse the order of elements in a
givenlist.However,therearesyntaxandlogicalerrorsinthecode.Rewrite it after
removing all errors. Underline all the corrections made.
defreverse_list(lst)
if not lst:
return (2)
lstreversed_lst=lst[::-
1] return reversed_lst
print("Reversedlist:"reverse_list[1,2,3,4])
27. (I)
A) Whatconstraintshouldbeappliedtoatablecolumntoensurethatall values
in that column must be unique and not NULL?
OR
B) Whatconstraintshouldbeappliedtoatablecolumntoensurethatitcan have
multiple NULL values but cannot have any duplicate non-NULL values? (2)
(II)
A) Write an SQL command to drop the unique constraint named
unique_emailfromacolumnnamedemailinatablecalledUsers.
OR
B) WriteanSQLcommandtoaddauniqueconstrainttotheemailcolumn of an
existing table named Users, ensuring that all email addresses are unique.
Ans:(I)(A):UsetheUNIQUEconstraintalongwiththeNOTNULLOR
PRIMARY KEY constraint.
OR
(B):UsetheUNIQUEconstraintalone,allowingformultipleNULL
values.
Example:column_nameINTUNIQUENULL
(II)(A):ALTERTABLEUsersDROPCONSTRAINTunique_email;
OR
(B):ALTERTABLEUsersADDCONSTRAINTunique_emailUNIQUE (email);
(1markeachforcorrectpartforeachquestionsanycorrectexample as
ananswer is acceptable )
Page:9/22
28. A) Explainoneadvantageandonedisadvantageofmeshtopologyin
computer networks.
OR (2)
B) ExpandthetermDNS.WhatroledoesDNSplayinthefunctioningofthe
Internet?
Ans:
(A) :AdvantageofMeshTopology:Highredundancy;ifoneconnection fails,
data can still be transmitted through other nodes.
DisadvantageofMeshTopology:Complexityandhighcost;requires more
cabling and configuration compared to simpler topologies.
OR
29. A) Write a Python function that extracts and displays all the words present in a
text file “Vocab.txt” that begins with a vowel..
OR (3)
B) Write a Python function that extracts and displays all the words
containing a hyphen ("-") from a text file "HyphenatedWords.txt", which
has a three letter word before hypen and four letter word after hypen.
For example : “for-them” is such a word.
Ans :A)
defdisplay_words_starting_with_vowel():
vowels = 'AEIOUaeiou'
withopen('Vocab.txt','r')asfile:
words=file.read().split()
#Loopthroughthewordsandcheckifthefirstletterisavowel for
word in words:
ifword[0]invowels: print(word)
B)
def display_specific_hyphenated_words():
withopen('HyphenatedWords.txt','r')asfile:
words=file.read().split()
#Loopthroughthewordsandcheckiftheymatchthepattern for
word in words:
parts=word.split('-')
#Checkifthewordishyphenatedandmatchestheformat"XXX- XXXX"
iflen(parts)==2andlen(parts[0])==3andlen(parts[1])==4: print(word)
Page:10/22
1/2 mark forfileopening+1/2 mark forcorrectloop+1/2markfor
correctuseofsplit()+1markforcorrectcondition+1/2markfor output
(A) You have a stack named MovieStack that contains records of movies.
30. Each movie record is represented as a list containing movie_title,
director_name,andrelease_year.Writethefollowinguser-definedfunctions in
Python to perform the specified operations on the stack MovieStack:
(II) pop_movie(MovieStack):Thisfunctionpopsthetopmostmovierecord
from the stack and returns it. If the stack is empty, the function should
display "Stack is empty".
OR
Writethefunctiondisp_odd()todisplayallelementsofthestackwithout deleting
them. If the stack is empty, the function should display "None".
For example:
IftheintegersinputintothelistNUMBERSare:[7,12,9,4, 15]
ThenthestackOddNumbersshouldstore:[7,9,15]
Ans:(A)
def push_movie(movie_stack, new_movie): #1mark
movie_stack.append(new_movie)
def pop_movie(movie_stack):
Page:11/22
return movie_stack.pop()
defpeek_movie(movie_stack):
return "None"
returnmovie_stack[-1]
OR
(B)defpush_odd(M,odd_numbers):
if number % 2 != 0:
odd_numbers.append(number)
def pop_odd(odd_numbers):
returnodd_numbers.pop()
def disp_odd(odd_numbers):
return "None"
returnodd_numbers
Page:12/22
31. Predicttheoutputofthefollowingcode:
data=[3,5,7,2]
result=""
fornumindata:
for i in range(num):
result+=str(i)+"*"
result=result[:-1]
print(result)
OR
Predicttheoutputofthefollowingcode: (3)
numbers = [10, 15, 20]
for num in numbers:
forjinrange(num//5):
print(j,"+",end="")
print()
Ans: 0*1*2*0*1*2*3*4*0*1*2*3*4*5*6*0*1
(1markforpredictingcorrectoutputsequenceof numbers
+ 1 mark for predicting correct placement of * + 1
mark for removing last * )
OR
0+1+
0+1+2+
0+1+2+3+
(1MARKForputtingoutputinthreelines+1markfor predicting
correct sequence of numbers in each line ( 1/2 for
incorrect partially correct) + 1 mark for
correctplacementof+)
QNo. Section-D( 4x4=16Marks) Marks
32. ConsiderthetableORDERSasgivenbelow
Ans:(A)(1MARKEACH)
(I) SELECTProduct,SUM(Quantity)ASTotal_Quantity
FROM ORDERS
GROUP BY Product
HAVINGSUM(Quantity)>=5;
(II) SELECTO_Id,C_Name,Product,Quantity,Price
FROM ORDERS
ORDER BYPriceDESC;
(III) SELECTDISTINCTC_Name
FROM ORDERS;
(IV) SELECTSUM(Price)ASTotal_Price_Null_Quantity
FROM ORDERS
WHERE QuantityISNULL;
OR
(B)(1MARKEACH) (I)
C_NameTotal_Quantity
Jitendra 1
Mustafa2
Dhwani1
Alice 1
David NULL
(II)
O_IdC_Name Product Quantity Price
1002MustafaSmartphone2 10000
1004Alice Smartphone1 9000
Page:14/22
(III)
ACSVfile"HealthData.csv"containsthedataofahealthsurvey.Each record of
33. the file contains the following data:
Nameof a country
LifeExpectancy(averagenumberofyearsapersonisexpectedto live)
GDPpercapita(GrossDomesticProductperperson)
Percentageofpopulationwithaccessto healthcare
Forexample,asamplerecordofthefilemaybe:['Wonderland',82.5,40000, 95].
(4)
WritethefollowingPythonfunctionstoperformthespecified operations on
this file:
(II)Countthenumberof recordsinthefile.
Ans:(I)
importcsv
def read_health_data(filename):
records=[]
withopen(filename,mode='r')asfile:
reader = csv.reader(file)
next(reader)#Skiptheheaderrowifpresent for
row in reader:
country = row[0]
life_expectancy=float(row[1])
gdp_per_capita= float(row[2])
access_to_healthcare=float(row[3]) if
life_expectancy > 75 :
records.append([country,life_expectancy,gdp_per_capita,
access_to_healthcare])
returnrecords
Page:15/22
(II)
defcount_records():
records=read_health_data(“HealthData.csv”)
return len(records)
Alex has been tasked with managing the Student Database for a High
34. School.HeneedstoaccesssomeinformationfromtheSTUDENTSand
SUBJECTS tables for a performance evaluation. Help him extract the
following information by writing the desired SQL queries as mentioned
below.
Table:STUDENTS
FNam Mark
S_ID LName Enrollment_Date
e s
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90 (4)
203 Alex Johnso 22-11-2021 75
n
204 Emily Davis 30-01-2022 60
Micha
205 Brown 17-08-2018 95
el
Table: SUBJECTS
Ans: (I )
SELECT*FROMSTUDENTSS
JOINSUBJECTSSubONS.S_ID=Sub.S_ID
WHERE S.Marks > 70;
Page:16/22
(II)
SELECT*
FROMSUBJECTS
WHERECreditsBETWEEN2AND4; (III)
UPDATESUBJECTS
SETCredits=Credits+1
WHERESubNameLIKE'%Science%';
(IV) A:
SELECTFName,LName FROM
STUDENTS S
JOINSUBJECTSSubONS.S_ID= Sub.S_ID
WHERESub.SubName='Mathematics'; OR
B:
SELECT*
FROMSTUDENTS,SUBJECTS;
Atable,namedELECTRONICS,inthePRODUCTDBdatabase,hasthe following
35. structure:
Field Type
productID int(11)
productNamevarchar(20)
price float
stockQty int(11)
(4)
WritethefollowingPythonfunctiontoperformthespecifiedoperation:
Ans:
importmysql.connector
def AddAndDisplay():
#Connecttothedatabase
conn=mysql.connector.connect(
host='localhost',
user='root',
password='Electro123',
database='PRODUCTDB'
)
cursor=conn.cursor()
productID=int(input("EnterProductID:"))
Page:17/22
productName=input("EnterProductName:") price
= float(input("Enter Price: "))
stockQty=int(input("EnterStockQuantity:"))
cursor.execute("INSERTINTOELECTRONICS
(productID, productName,
price,stockQty)VALUES(%s,
%s, %s, %s)", (productID,
productName,price,stockQty))
conn.commit()
cursor.execute("SELECT*FROMELECTRONICS
WHEREprice>150")
records = cursor.fetchall()
print("\nRecordswithpricegreaterthan150:") for
record in records:
print(record)
cursor.close()
conn.close()|
(1Mark forDeclarationofcorrectConnection Object
+1 Mark forcorrectinput+1 marksfor correctly
usingexecute()method+1marksforshowing output
using loop )
Ans : (I)
importpickle
def add_employee(filename):
employee_id = int(input("Enter Employee ID: "))
employee_name=input("EnterEmployeeName:") position
= input("Enter Position: ")
salary=float(input("EnterSalary:"))
new_employee=(employee_id,employee_name,position,salary) with
open(filename, 'ab') as file:
pickle.dump(new_employee,file)
Page:18/22
data)
(II)
defupdate_employee(filename):
employees = []
withopen(filename,'rb')asfile: try:
while True:
employees.append(pickle.load(file))
exceptEOFError:
pass
foriinrange(len(employees)): if
employees[i][3] > 50000:
employees[i]=(employees[i][0],employees[i][1],"TeamLead",
employees[i][3])
withopen(filename,'wb')asfile: for
employee in employees:
pickle.dump(employee,file)
(1markforcorrectuseofload()methodtoretrievedata+1/2markfor correct
loop + 1/2 mark for correct condition within loop )
(III)
def display_non_team_leads(filename):
print("\nEmployeeswhoarenotTeamLeads:") with
open(filename, 'rb') as file:
try:
while True:
employee= pickle.load(file)
ifemployee[2]!="TeamLead":
print(f"ID:{employee[0]},Name:{employee[1]},Position:
{employee[2]},Salary:{employee[3]}")
except EOFError:
pass
(1markforcorrectuseofTryexceptblockand1/2markforcorrect use of
while loop )
Page:19/22
Interstellar Logistics Ltd. is an international shipping company. They are
37. planningtoestablishanewlogisticshubinChennai,withtheheadofficein
Bangalore. The Chennai hub will have four buildings - OPERATIONS,
WAREHOUSE, CUSTOMER_SUPPORT, and MAINTENANCE. As a
networkspecialist,yourtaskistoproposethebestnetworkingsolutionsto address
the challenges mentioned in points (I) to (V), considering the distances
between the various buildings and the given requirements.
(5)
Building-to-BuildingDistances(inmeters):
From To Distance
OPERATIONS WAREHOUSE 40 m
OPERATIONS CUSTOMER_SUPPORT 90 m
OPERATIONS MAINTENANCE 50 m
WAREHOUSE CUSTOMER_SUPPORT 60 m
WAREHOUSE MAINTENANCE 45 m
CUSTOMER_SUPPORT MAINTENANCE 55 m
DistanceofBangaloreHeadOfficefromChennaiHub:1300km Number
Location Computers
OPERATIONS 40
WAREHOUSE 20
CUSTOMER_SUPPORT 25
MAINTENANCE 22
BANGALOREHEADOFFICE15
Page:20/22
(I) SuggestthemostsuitablelocationfortheserverwithintheChennaihub.
Justify your decision.
(II) Recommendthehardwaredevicetoconnectallcomputerswithineach
building efficiently.
(III) DrawacablelayouttointerconnectthebuildingsattheChennaihub
efficiently.Whichtypeofcablewouldyourecommendforthefastestand most
reliable data transfer?
(IV) Isthereaneedforarepeaterintheproposedcablelayout?Justifyyour
answer.
a)Video Conferencing
b) Email
c)Telephony
d)Instant Messaging
OR
Ans :
(I) TheservershouldbeplacedintheOPERATIONSbuilding.
Justification:
Ithasthelargestnumberofcomputers(40),makingitthemost
central location in terms of the network load.
Thedistancestootherbuildingsarerelativelyshort,ensuring
efficient data transfer. (1 Mark)
(III) Themostefficientcablelayoutwouldinvolveconnectingthe
buildings as follows:
OPERATIONStoWAREHOUSE (40 m)
OPERATIONStoMAINTENANCE(50m)
OPERATIONStoCUSTOMER_SUPPORT(90m)
WAREHOUSEtoMAINTENANCE(45m)
WAREHOUSEtoCUSTOMER_SUPPORT(60m)
Page:21/22
CUSTOMER_SUPPORT
(90m)
OPERATIONS
/ | \
(40 m)(50m)(60 m)
/ | \
WAREHOUSEMAINTENANCE
CableRecommendation:Fiberopticcableisrecommendedforhigh- speed
data transfer and reliable communication over distances. It offers
better bandwidth and lower signal degradation over long distances
than copper cables.( 1/2 + 1/2 mark)
(III) There is no need for a repeater in this layout. The maximum distance
betweenanytwobuildingsis90meters,whichiswellwithinthe100-meter limit
for Ethernet cable or fiber optics before requiring a repeater.
( 1mark)
(IV) A) The best option for live communication between the Chennai
Operations Office and the Bangalore Head Office would be Video
Conferencing.Thisallowsreal-timeface-to-facemeetingsandvisual
communication across long distances, which is ideal for inter-office
collaboration.
OR
(V) B)ThenetworktypeintheChennaihubwouldbeaLAN(LocalArea
Network), as all computers are located within a confined geographical
area (the logistics hub) and are connected to each other for data
communication within the same campus.
(1markforanycorrectpart solution )
Page:22/22