Computer Science Question Paper 2024
Computer Science Question Paper 2024
Set-4
Q.P . Co de
COMPUTER SCIENCE
Tim e all ow ed : 8 hou rs
Ma xim um Marks : 70
NO TE
219 1 1 P.T.O.
General Instru ctions :
. (i) Please check this question paper contains 35 queS t i0 ns.
(ii) The paper is divide d into 5 Sections -A, B, C, D a nd E.
(iii) Sectio n A, consists of 18 questions (1 to 18). Each question carrie
s
1 mark.
(iv) Sectio n B, consists of 7 questions (19 to 25). Each question, carrie
s
2 marks. •
(v) Sectio n C, consists of ·5 questions (26 to 30). Each questi on carries
3 marks .
(vi) Sectio n D, consists of 2 questions (31 to 32). Each questi on carrie
s
4 marks . .
(vii) Sectio n E, consists of a questions (33 to 85). Each questi on carrie
s
5 marks .
(viii) A_ll progra ,mmin g questi ons are to be answe red using Pytho n Langu
age
only.
SECT ION- A
1. State True or False : 1
While_ defmi ng _a function in Python, the positional param eters in the
function heade r must always be writte n after the defaul t param eters.
2. The SELECT statem ent when combined with ___ _ clause , return s
records witho ut repetition.
1
(a) DISTINCT (b) DESCRIBE
(c) UNIQUE • (d) NULL
4. What possible outpu t from t~e given options is expected to be displa yed
when the following Pytho n code is executed ?
1
impor t random
Signa l =['RED ', 'YELLOW', 'GREEN']
for Kin range (2, 0, -1) :.
·R = rando m.ran drang e(K) •
prin t (Sign al[R] , end= '#')
(a) YELLOW # RED # (b) RED # GREEN #
(c) GREEN # RED # (d) YELLOW # GREEN #r
2191 2
,
I
6. Which protocol out of the following is used to send and receive emails over
a computer network ?
1
(a) PPP (b) HTTP
(c) FTP (d) SMTP
8. Consider the statem ents given below and then choose the correct outpu t
from the given options : 1
myStr ="MI SSISS IPPI"
prin t (mySt r [: 4] +"#"_+myStr [-5:] )
(a) MISS I#SIP PI (b) MI~S #SIPf I
(c) MISS #IPPI S (d) • MISS I#IPP IS
9. Identi fy the statem ent from the following which will raise an error :
1
(a) print ("A" *3) (b) print (5*3)
(c) print ("15" + 3) (d) prin t (" 15" + "13")
(c) Hz (d) Km
1
12. Obser ve the given Pytho n code carefu lly ;
a=20
def conv art(a ):
b=20
a=a+b
conv ert(lO )
print (a)
Select the correc t outpu t from the given option s :
(a) 10 (b) 20
1
13. State wheth er the following statem ent is True or False :
While handling. exceptions in Pytho n, name of the excep tion has to be
compulsorily added with exce pt clause.
i
1
. ,. the following Pyth on stat eme nt :
16 Cons1de
• ,-op en ( ' CONTENT . 'l'X'l' ' )
Which of the following is an inva lid stat eme nt
in Pyth on ?
~) F.s eek (l,O ) • (b) F.s eek (0,1 )
.
SEC TIO N-B
19. {A) (i) Exp and the following term s : 1+ 1= 2
XML, PPP
{ii) Give one difference betw een circ uit swit chin g and pac ket
swit chin g.
OR
(B) (i) Define the term web host ing.
(ii) Nam e any two web brow sers .
2191 5 P.T. O.
I
20. The code given below accepts five numbers and displays whether they are
even or odd: 2
,
Observe the following code carefully and rewrite it after removing all
syntax and logical errors :
Underline all the corrections made.
def BvenOd.d ()
for i in ranga(5):
nwn=int(input("E ntar a number")
i f nwn/2==0 : · ·
print ("Evan")
a1sa:
print ("Odd")
EvenOdd(f
21. (A) Write a user defined function in Python named showGrades (S)
w~ich takes the dictionary S as an argument. The dictionary,
• >
\ .
Write a user defined function in Pytho n named Puzzl e (W, N) which
(B)
takes the argum ent W as an English word and N as an integer and
return s the string where every Nth alphab et of the word Wis.replaced
with an underscore ("_" ) .
For example : if Wcontains the word "TELEVISION" and N is a, then
the function should return the string "TE_EV_SI_N". Likewise for the
word "TELEVISION" if N is 4, then the function should return
"TEL_VIS_ON".
22. Write the outpu t displayed on execution of the following Pytho n code
: 2
LS= ["HIMALAYA" , · "NILGIRI" , "ALASKA" , "ALPS"]
D={}
for Sin LS:
if len(S) %4 =
0:
D[S] len(S )
for.K in D:
print (K,D[ K], sep = "#")
23. (A) Write the Pytho n statem ent for each of the following tasks using
built-i n functions/methods only :
I
•
1+ 1=2
(i) To remove the item whose key is "NISHA" from a dictio nary
name d Stude nts.
For example, if the dictio nary Stude nts conta ins
{"ANI TA": 90, "NISHA": 76, "ASHA": 92 }, then after remov al
the dictio nary should contai n {"ANITA": 90, "ASHA": 92}
(ii) To displa y the numb er of occurrences of the substr ing "is" in a
string name d mess age.
For examp le if the string messa ge contai ns "This is his
book" , then the outpu t will be 3.
OR
(B) A tuple nam"ed subje ct stores the names of different subjects. Write
the Pytho n commands to convert the given .tuple to a list and
therea fter delete the last eleme nt of the list.
2191 7 P.T.O.
/1
(
med spo rt• in a M.'7sQL data base ,
24. (A) Ms. Veda crea ted a table na
.r
.~. and G name.
cont ainin g colu mns aam e_.... d , p_,.,,,. 2
- .
-V1
#
Afte r crea ting the table , she reali zed that the attri
has to be adde d. Help her to writ e a com man d to
bute , C:..tegoey
add the Ca.t. .g0 ey
colu mn. The reaf ter, writ e the com man d to inse rt the
following reco- rd
in the tabl e :
Gama_id : G42
P_A ge : Abo ve 18
G_nama : Che ss
OR
(B) Wri te the SQL ~ommands to perf orm the following
task s :
(i) View the list of tabl es in the data base , Exam .
(ii) View the stru ctur ~ of the tabl e, Term l .
2191 9· P.T.O.
28. (A) Wri te a use r d e fiine d func tion in Pyt hon
. d d
natn ed sho win Lin es ()
•
I
whi ch rea s con e t nts of a text file nam e STO a-y • 'rXT and disp \(
lays
eve ry sen tenc e in a sep arat e line .
• •
Ass ume tha t a sen tenc e end s wit h a full st0
P (.), a que stio n mar k(? ),
or an exc lam atio n mar k(!) .
For exa mpl e, if the con tent of file STORY. TXT
is as foll ows :
Our par ent s tol d us tha t we mu
st eat veg eta b~e a to be
hea lth y. And i t tur ns out , our
par ent s wer e rig ht\ So,
wha t els e did our par ent s tel l?
The n the fun ctio n sho uld disp lay the file's con
tent as follows : •
Our par ent s tol d us tha t we mu st eat veg eta ble s to be
hea lth y.
And i t tur ns out , our par ent s we
re. rig ht!
So, wh at els e did our par ent s tel
l?
OR
(B) Wr ite a fun ctio n, c wor ds () in Pyt hon
- tha t sep ara tely cou nts and
disp lay s the num ber of upp erc ase and low erca -
se alp hab ets in a text.
file, Words . txt .
-
1 p
id Pna me Lan gua ge Sta rtd ate
I, End dat e
P00 1 Sch ool . Ma nag eme nt
Pyt hon 202 3-0 1-1 2 202 3-0 4-0 3
Sys tem
P00 2 Ho tel Ma nag eme nt c++ 2O 22- 12- Oi 202 3-0 2-0 2
Sys tem ..
(ii) PopBig () : _It pops the number s from the stack, BigNum s and
displays them. The function should also display "Stack Empty"
when there are no more number s left in the stack.
For example: If the list Nums contain s the following data :
I
Nums = [213,1 0025,1 67,254 923,14 ,12976 53,314 98,386 ,92765 ]
Then on execution of PushB ig () , the stack BigNums should store :
.
[10025 , 254923 , 129765 3, 31498, 92765]
And on execution of P~pBig () , the follow~g out~ut should be displayed :
92765
31498
129765 3
254923
10025
Stack Empty
SECTI ON-D
31. Conside r the tables Admin and Transp ort given below : lx4=4
Tabla : Ad.min
-
Sid
S001
-
S name
Sandhy a
Addres s
-
S type
Rohini Day Boarde r
S002 Vedan shi Rohtak Day Schola r
S003 Vibhu Raj Hagar NULL
S004 Atharv a ~ampur Day Boarde r
2191 11 P.T.O.
I
Tab le: Tran sport
-
Sid
S002
-
Bua no
TSS10
Stop_name
Sara i Kale Khan
S004 TSS12 Sain ik Viha r
S005 TSS10 Kull a Hagar
Write SQL queries for the following :
(1.) n·1splay the stude nt name_ and thei·r stop name from the table s
Adm.in and Tran sport .
(ii) Display the number of stude nts whose S_ type is not known.
(iii) Dis;play a~ details of the stude nts whose name start s with 'V'
•
(iv) Display stude nt id and addre ss in alpha betic al order of stude
nt
name , from the table Adrni n.
Sang eeta wants to write the following user defin ed funct ions :
Add_ Devic e () : to accept a record from _the user and add it to
a csv· file
Perip hara l.csv . • '
Coun t_Da vice () : To count and displa b .
. . Y num er of penp heral devices
whose price is less than 1000.
2191
12
SEC TION -E
. • pt Ltd. is an event mana geme nt company with its prime
office
33
• :::::: :~en galu ru. The company is planning to open its new
division at
three different locations in Chen nai n_amed as - Vajra, Tris.h
ula and
Sudershana.
1 x 5 =5•
y 0 u, as a networking exper t need to suggest solutions to the quest
ions in
part (i) to (v), keeping in ~ind the distan ces and other given parameters_
.
Bengaluru
Office
Chennai Division
Vajra Trishula
Suder shana
34. (A) (i) Dif fer ~nt iate bet we en ' w' and ' a' file
modes in Pyt hon . 2 + 3 =t
(ii) Co nsi der a bin ary
file, ite ms .da t, con tain ing rec ord s sto
red in
the giv en for ma t :
{it em _id : [ite m_ nam e,a mo un t]}
Wr ite a function, Copy_new(), t~a
t copies all records whose
am oun t is gre ate r tha n 1000 from ite
da t. -
ms .da t to new ite ms .
OR
(B) (i) Wh at is the advantage of usi ng wi th cla
use while opening a dat a
file in Pyt hon ? Also give syn tax of wi th
clause.·
(ii) A bin ary file, EMP . DAT has the
following str uct ure :
[Emp_Id, Name, Sa lar y]
wh ere
-
Emp Id : Employee. id
Name : Employee Na me
-
F code : Flight code (String)
'
.•
-
F name : Name of flight (String)
.
Sou~ ce : Depar ture city of flight (String)
Dest inati on: Destin ation city of flight (String)
Consi der the following to establ ish connectivity betwe en Pytho n
andM ySQL :
• Usern ame : root
• Passw ord : airpl ane
• Host : local host
2191 15
2191 16