You are on page 1of 13

Outside Delhi Set-IFully Solved by Om Kale, Marks

Obtained in Computer Science 2023 Boards-100/100


Time:3 Hours Max. Marks :8

GeneralInstructions;
) This question paper contains five sections, Section A to E.
(i) All questions are compulsory.
öi) Section A have 18 questions carrying 1 mark each.
(in) Section Bhas 7 Very Short Answer type questions carrying 2 marks each.
in) Section C has 5 Short Answer type questions carrying 3 marks each.
(m) Section D has 3 Long Answer type questions carrying 5 marks each.
(oi) Section Ehas 2questions carrying 4marks each. One internal choice is given is Q.34 and 35, against Part (i) only.
(vi) All programming questions are to be ansuered using Python Language only.
"This Rrper is solely for reference purpose. The patern of the paper has been changed for 2024 Exam which is been followed in subscoquent Sample fupers.

SECTION -A
1. State True of False.
"Identifiers are names used to identify a variable, function in a program".
Ans.e
2. Which of the following is a valid keyword in Python?
(a) false (b) return
(c) nonlocal (d) none

Ans. C) ctun
3. Given the following Tuple
Tup= (10, 20, 30, 50)
Which of the following statements will result in an error?
(a) print (Tup [0]) (b) Tup.insert (2,3)
(c) print (Tup [1:2]) (d) print (len (Tup) )

Ans. () Tup iMaxt (2,3)


4. Consider the given expression:
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is evaluated?
(a) True (b) False
(c) NONE (d) NULL

Ans. TRuus udflee oe lale

Tue Fale
Te
OswaalCBSE Sample Question Papers, COMPUTER SCIENCE, Class-XIl
16
of the code:
5. Select the correct output @ 75"
S "Amrit Mahot sav
A=S.partition (" ")
print (A)
(a ('Amrit Mahotsav', '0,75) (b) 'Amrit', 'Mahotsav', '',751
('Amrit', 'Mahotsav @ 75') (d) ('Amrit',
(c) ,'Mahotsav@ 75')
Ans.

6Which of the following mode keeps the file offset position at the end of the file?
(a) r+ (b) r
(c) w (d) a

Ans.

7. Fill in the blank.


function is used to arrange the elements of a list in ascending order.
(a sort () (b) arrange ()
(c) ascending () (d) asort ()

Ans. (a) Sottl)


8. Which of the following operators will return either Irue or False?
(a) (b) !=
(d) *=
(c)

Ans.

9. Which of the following statemernt(s) would give an error after executing the following code?
stud={"Murugan" :100, "Mithu" :95} # Statement 1
print (stud [95] ) # Statement 2
Stud ("Murugan"]=99 # Statement 3
print (Stud. pop (0) # Statement 4
print (Stud) # Statement 5
(a) Statement 2 (b) Statement 3
(c) Statement 4 (d) Statement 2 and 4

Ans.

10, Fillin the blank.


is a number of tuples in a relation.
(a) Attribute (b) Degree
(c) Domain (d) Cardinality
Ans.

11. The syntax of seek () is :


file object . seek (offset [, reference point])
What is the default value of reference point?
(a) 0 (b) 1
(c) 2 (d) 3
Ans.

12. Fillin the blank:


.. clause is used with SELECT tatement to display data in asorted form with respect to aspecified column.
(a) WHERE (b) ORDER BY
(c) HAVING (d) DISTINCT
Solved Paper-2023 17

Ans.

13. Fillin blank:


is used or point-to-point communication or unicast communication such as radar and sarenite.
(a) INFRARED WAVES (b) BLUETOOTH
(c) MI CROWAVES (d) RADIOWAVES

Ans. L(O MICROWAVES


14. What will the following expression be evaluated to in Python?
print (4+3*5/3-5%2)
(a) 8.5 o e oee (b) 8.0
(c) 10.2 (d) 10.0

Ans. 4+ 5/3- 5.2


: 4 45.0- 1 = 8.o

a list?
15. Which function returns the sum of all elements of
(a) count () (b) sum ()
total ()
(d) add ()
(c)
Ans. ) SUm()
ina result set and returns a:
16. Fetchall) method fetches all rows (b) List of tuples
(a) Tuple of lists
List of strings (d) Tuple of strings
(c)
Ans.
REASONING (R) based questions.
0.17 and 18 are ASSERTION (A)and
Mark the correct choice as
(A) and (R) are true and (R) is the correct explanation for (A).
(a) Both correct explanation for (A).
are true and (R) is not the
(b) Both (A) and (R)
false.
(c) (A) is true but (R) is
(d) (A) is false but (R) is true. particular module, we need to import the
module.
module.
17. Assertion (A): To use a
function from a
anywhere in the program, before using a function from that
be written
Reason (R): import statement can
Ans.
existing
18. Assertion (A): Astack
is aLIFO structure.
always gets positioned at the index after the last
pushed into the stack
Reason (R): Any new element
element in the stack.

Ans. ( [20 Marks]


SECTION -B
be list. The
SCIENCE, Class-XII
18 OswaalCBSE Sample Question Papers, COMPUTER

Ans.

Hutnn Max
20. (a) Differentiate between wired and wireless transmission.
OR

(b) Differentiate between URL and domain name with the help of an appropriate example.
Ans.
Wixae)
fhuical akal oud CallesNo angilla nnedeial

Maitennca is catly Maivtenace is ea


21. (a) Given is a Python list declaration:
Listofname s=["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]
Write the output of:
print (Listo fnames (-1: -4:-1])
(b) Consider the following tuple declaration:
tupl= (1 0, 20,30, (10,20,30) , 40)
Write the output of:
print (tupl. index (20))
Ans. Annu Ankit Askish kaian Kaijot
-S -3 -2

22. Explain the concept of "Alternate Key' in aRelational Database Management System with an approprate eanp)
Ans.
key ae called altenate heys

NAME AGE GENDER


ZO3 Kisnaa 25 F
ZOG Govivd 28 M
ZOR Kadha 20

ZI| Madhav 29 M
23. (a) Write the full forms of the following:
(i) HTML
(i) TCP
(b) What is the need of Protocols?

Ans.

a
Solved Paper 2023 19

a (a) Write the output of the code given below:


def short sub (lst,n) :
for i in range (0,n):
if len (lst) >4:
lst [i] =lst [i]+lst [i]
else:
lst [i] =lst [i)
subject= ['CS', 'HINDI', PHYSICS!, "CHEMISTRY, MATHSI
short sub (subject, 5)
print (subject )
OR
(b) Write the outputof the code given below:
a -30
def call (x):
global a
if at2==0:
X+=a
else:
X-=a
return x
X=20
print (call (35) , end="#")
print (call (40), end= "@")
Ans.
3022==0
30+ x= 0+35 ’ 5 -- O
K=30+4O: 7o -

25. (a) Differentiate between CHAR and VARCHAR data types in SQL with appropriate example.
OR
(b) Name any twoDDL and any two DML commands.

Ans. DDL: ALTER DROP


DML: SELECT, DELETE
SECTION -C
26. (a) Consider the following tables LOAN and BORROWER:
Table: LOAN

LOAN NO B NAME AMOUNT


L-170 DELHI 3000
L-230 KANPUR 4000

Table: BORROWER
CUST NAME LOAN NO
JOHN L-171
KRISH L-230
RAVYA L-170

How many rows and columns willbe there in the natural join of these two tables?
OR
(b) Write the output of the queries (i) to (iv) based on the table, WORKER given below:
TABLE:WORKER
W ID F_NAME L NAME CITY STATE
102 SAHIL KHAN KANPUR UTTAR PRADESH
Question Papers,
COMPUTERSCIENCE, Class-XII
20 OswaalCBSE Sample
ROOP NAGAR PUNJAB
SAMEER PARIKH
104
DELHI DELHI
MARY JONES HARYANA
105 SONIPAT
MAHIR SHARMA
106
DELHI
DELHI
107 ATHARVA BHARDWAJ
UTTAR PRADESH
SHARMA KANPUR
108 VEDA
ORDER BY STATE DESC;
(i) SELECT F NAME, CITY FROM WORKER
(i) SELECT DISTINCT (CITY) FROM WORKER; HA%;
L NAME LIKE
(ii) SELECT F NAME, STATE FORM WORKER WHERE
(iv) SELECT CITY, COUNT(*) FORM WORKER GROUP BY CITY;
Ans.
Natoral jsin adwhen ouly comneiels
ae displayed
ence 2 ou and 4 colune.
27. (a) named definition of a Python function named LongLines () which reads the contents
Write the' LINES atext
. TXT' and displays those lines from the file which have at least 10 words in it
For example, if the content of 'LINES.TXT' is as follows:
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw alittle girl skipping through the woods, whistling happily.
The girl was followed by abig gray wolf.
Then the function should display output as:
He lives in a little house in a beautiful, green wood.
He saw alittle girl skipping through the woods,whistling happily.
OR
(b Write afunction count Dwords () in Python to count the words ending with adigit in atext file "Deta: 2
txt"
Example:
If the file content is as follows:

On seat2 VIPl will sit and


On seatl VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4

Ans.
def Louglines():
opeuLINEStxt"")
L= xeadlinael)
y=X Split(.
pit(x
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the
Table:COMPUTER relations COMPUTER and SALES given beo
PROD ID PROD NAME PRICE COMPANY TYPE
PO01 MOUSE 200
PO02 LOGITECH INPUT
LASER PRINTER 4000 CANON OUTPUT
PO03
PO04
KEYBOARD 500 LOGITECH INPUT
JOYSTICK 1000 IBALL INPUT
PO05
PO06
SPEAKER 1200 CREATIVE OUTPUT
DESKJET PRINTER 4300 CANON OUTPUT
Table: SALES
PROD ID OTY SOLD
PO02 QUARTER
4 1
PO03 2 2
PO01
PO04 2
Solved Paper 2023 21

(i) SELECT MIN (PRICE) , MAX (PRICE) FROM COMPUTER:


(COMPANY)
(1) SELBCT COMPANY, COUNT (*) FROM COMBUrED cBoUP Y cOMPANY HAVING COUNT
PROD
(i1) SBLBCT PROD NAME, QTY SOLD FROM cOMPUTER C. SALES 8 WHERE C. PROD ID=S.
ID AND TYPE INPUT':
(iv) SELECT PROUD NAME, COMPANY, OUARTER FORM COMPUTER C, SALES S WHEREho
ID=S. PROD IDF
(b) Write the command to view all databases.
Ans. MIN CoRIcE) MAx (PRICE)
200
4300
ComPANY CoUrNT C*)
LOGITECH 2
CANON 2

PROD LNAME QTY_ SoLD


MoUSE
KEYBOARD
JoySTiCk 2

PROD_NAME CoMNYQUARTER
LOGITECH 2
moUsE
LASER PRINTER CANON
KEYBOARD LOGIECH 2
IeAL 1
DYSTCKk
SEAKER CREATIVE NULL
DESKSET fRINTER CANON NULL

SHoW DATABASES
Thereafter, it increments all even
Write a functions EOReplace () in Python, which accepts a list L of numbers.
29. numbers by 1.
numbers by 1 and decrements all odd
Example:
If Sample Input data of the list is:
L= (10, 20, 30, 40, 35, 55)
Output will be:
L=(11,21, 31, 41,34, 54)

Ans
del EoReglaca ():
x in L:
Lot ifx2=50:
LIL.indexC07 +=1

DL[L.index)-=1
iut ("L="
EoRaplaca ()
22 Oswaal CBSE Sample Question Papers, COMPUTER SCIENCE, Class XII

30. (a) Alist contains following record of customer.


ICust omer hame, Room Typel
Write the following user defined functions to perform given operationson thes
stack name
() Push Cust ()-To Push customer' names of those customers who are staying in
() Pop Cust () -- To Pop the names of customers from the stack and Delux
Underflow" when there are no customers in the stack. display them.
For example:
IF the lists withcustomer details are as follows:
No,
Siddarth" , "Delux")
["Rahul", "Standard")
["Jerry", "Delux" ]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
OR
containing details at
(b) Write a function in Python, Push (Vehicles) where, Vehicle is a dictionary
-(Car Name: Maker).
The function should push the name of car manufactured by "TATA" (including all the possible cases a.
Ta Ta, etc.) to the stack.
For example:
data:
If the dictionary contains the following"Nexon"
Vehicle={"Santro" : "Hyundai", : "TATA", "Safari" : " Tata" }
The stack should contain
Safari
Nexon

f"Sants":" Hyundar" "Nexsn:"TATA


Ans. Q Vehicle = Satai:"Teta'
Stack = [3

== Vehiclas lx]. lauex ():


if "tata
Stack.apeud( )
Fosh(Velicle) ad
SECTION -D within
four branches(i)to(v)
up a network for its quuestions
is planning to set solutionsto the
located in Delhi network professional, give
and IT based firm, below:
Solved Paper-2023 23

Distance between various branches is as follows:


Branch Distance
Branch A to Branch B 40 m
Branch A to BranchC 80 m
Branch A to BranchD 65 m
Branch B to Branch C 30 m
Branch B to BranchD 35 m
Branch C to Branch D 15 m

Delhi Branch to Kanpur 300 km


Number of computers in each of the branches:
Branch Number of Computers
Branch A 15

Branch B 25

Branch C 40
Branch D 115
Delhi branch with a suitable reason.
(1) Suggest the most suitable place to install the server for the
within Delhi.
(ii) Suggest an ideal layout for connecting all these branches
placed in each of these branches to efficiently connect all the
(ii) Which devices will you suggest, that should be
computers within these branches?
to its Marketing department in Kanpur whichyour is approximately 300 km
(iv) Delhi firm is planning toconnect of formed? Justify answer.
away. Which type of network out LAN, WAN or MAN will be between Delhi and Kanpur
help for transferring of files
(v) Suggest a protocol that shall be needed to provide
branch.

Ans.
installe as it has the naaximunm number of
Canneuters

Sunch c)
BenchA)

i ) Hub
iv) wie Aea_Nehek CwA weeld Re used

V Fle Tanelerr fostocsl (ETe)


the time of execution of the following
32. (a) What pOssible output(s) are expected to be displayed on screen at
program:
import random
M= [5, 10,15, 20, 25, 30]
for i in range (1,3) :
first=random. randint (2, 5)-1
sec=random. randint (3,6)-2
third=random. randint (1, 4)
Class-XII
Papers,COMPUTER SCIENCE,
24 OswaalCBSE Sample Question
sep-"j")
print (M[first) , M[sec) , M[third] ,
(i) 10425#15
20#25#25
(i) 5425420
25#20#15
(iii) 30420420
20#25#25
(iv) 10#15#25#
15#20#10#
(b The code given below deletes the record from the table employee which
contains the
structure:
E code - String
E name - String
Sal -Integer
tol wing,
City -String
Note
"
the following to establish connectivity between Python and MySQL:
Username is root
Password is root
The table exists in a MySQL database named emp
The details (E code, E name, Sal, City) are the attributes of the table.
Write the following statements tocomplete the code:
Statement 1- to import the desired library.
Statement 2- to execute the command that deletes the record with E code as
'E101.
Statement 3 to delete the record permanently from the database.
import as mysql #Statement 1
def delete ():
mydb=mysql. connect (host="localhost",user="root",
passwd="root", database="emp")go
mycursor=mydb. cursor )
# Statement 2
# Statement 3
print ("Record deleted")AC
(a) OR
Predict the output of the code given below:
def makenew (mystr) :
newstr=" n
count=0
for i in mystr:
if count%2!=0:

newstr=newstrtstr (count)
else:
if i.lower ():
newstr=newstrti.upper ()
else:

newstr=newstr+i
Countt=1
print (newstr)
makenew ("No@1")
The code given below
reads the
who have employees
E code - coming fromfollowing records from the table employee andI displays onlythosered
city Delhi:
E
String
name - String
Sal - Integer
City - String
Note the following to
"
Username is root establish connectivity between Python and MySQL:
"
Password is root
The table exists in a
" The details (E MySQL database named emp.
code,E name, Sal, (City) ) are the
attributes of the table.
Solved Paper-2023 25

Write the following statements to complete the code:


Statement 1-toimport the desired library.
Statement 2- to executethe query that fetches ecords of the employees coming from city Den
Statement 3- to read the complete data of the auery (rows whose city is Delhi) into the object named
details, from the table emp loyee in the database.
import as mysql # Statement 1
def display ():
mydb=mysql . connect (host="localhost",user=" root",
passwd="root",database-"emp")
mycursOr=mydb.cursor ()
# Statement 2
details = # Statement 3
for i in details:
print (i)

Ans. Arut: (1,2,3, 4) o4234s


Sec: (4,2,3 )
third: (a,2,2,4)
(a)
Satut

nAydl.coitC)
33. (a) Write one difference between CSV and text files.
functions:
Write a program in Python that defines and calls the following user defined
csv'.
(i) cOURIER ADD () : It takes the values from the user and adds the details to a csv file courier.
Each record consists of a list with field elements as cid, s name, Source, destination to store
Courier ID, Sender name, Source and destination address respectively.
going to
(ii) coURIER SEARCH () : Takes the destination as the input and displays all the courier records
that destination.
ORM
(b) Why is important to close a file before exiting? functions:
Write a program in Python that defines and calls the following user defined consists
(i) Add Book() : Takes the details of the books and adds them to a csv file 'Book.csv'. Each record
of a list with field elements as book ID, B name and pub to store book ID, book name and publisher
respectively.
(ii) Search Book() : Takes publisher name as input and counts and displays number of books published by
them.

Ans.
and colMns whichs notth cala in a
g2netic Ctxt) le ssence bata modifcaton
and stoage much mate

smpot csV.
oith open C' cousinbe csy", w, nawline) f
COMPUTER SCIENCE, Class-XII
OswaalCBSE SampleQuestion Papers,
26

wkile caprel :
Manme
S.naa inpot ("lr eude
SKC Mput ("atr Sotce )

Xad, s.nam SHC dettJ

Ans. 33aD
del coUkIEK SEARCH () :

inp =input("uter destnatiey:


inp== x[3]:

CoURIER- ADb()
CoORIER SEARCH )
SECTION -E
34. The school has asked their estate manager Mr. Rahul to maintain the data of all the labs in a table LAB. Kanu
created a table and entered data of 5 labs.
LABNO LAB NAME INCHARGE CAPACITY FLOOR
Solved Paper-2023 27

(a) Add a constraint PRIMARY KEY to the column LABNO in the table.
(b) Delete the table LAB,

ns.

DUDATE LAS SET CAACITY=CARCITy +-10 wHERE RoRT";


5. Shreyas is a programmer, who has recently been given a task to write a user defined furnction named write
bin () to create a binary file called Cust ffle.dat containing customer information - customer number (c_
no), name (c_name), quantity (qty), price (price) and amount (amt) of each customer.
The function accepts customer number, name, quantity and price. Thereafter, it displays the message Quantty
less then 10... Cannot SAVE, if quantity entered is less than 10, Otherwise the function calculates amount as
price*quantity and then writes the record in the form of alist into the binary file.
import pickle
def write bin():
bin file= # Statement 1

while true:
c no=int (input ("enter customer number") )
Cname=input ("enter customer name")
qty=int (input ("enter qty") )
price=int (input ("enter price"))
if # Statement 2
print ("Quantity less than 10.. Cannot SAVE")
else:
amt=price * qty
c detail= [c no, c name, qty, price,amt]
# Statement 4
# Statement 5

#Statement 6
Write the correct statement to open afile 'Cust file .dat ' for writing the data of the custome.
(i)
(iü) Which statement should Shreyas fillin Statement 2 to check whether quantity is less than 10.
(iüü) Which statement should Shreyas fill in Statement 3 to write data to the binary file and in Statement 4 to stop
further processing if the user does not wish toenter more records.
OR
(Option for part (ii) only)
(ii) What should Shreyas fill in Statement 5 to close the binary file named Cust file . dat and in Statement 6
tocall a function to write data in binary file?

Ans.

pickle.domp Cc-tetail, ia lle


Stadenut 4: bheak

You might also like