Computer Science PYQs
Computer Science PYQs
page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse
www.cbse.page www.cbse
COMPUTER SCIENCE
NOTE
(I) Please check that this question paper contains 15 printed pages.
(III) Q.P. Code given on the right hand side of the question paper should be written
www.cbse.page on
www.cbse
(IV) Please write down the serial number of the question in the answer-book
before attempting it.
(V) 15 minute time has been allotted to read this question paper. The question paper
will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the students will
read the question paper only and will not write any answer on the answer-book
during this period.
91/S 1 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
General Instructions :
Please read the instructions carefully.
· This question paper has 5 Sections : Sections A, B, C, D, E.
· All questions are compulsory. However, an internal choice of approximately
30% is provided.
· Section A has 18 questions carrying 1 mark each.
· Section B has 7 Very Short Answer (VSA) type questions carrying 2 marks
each.
· Section C has 5 Short Answer (SA) type questions carrying 3 marks each.
· Section D has 2 Long Answer (LA) type question carrying 4 marks.
· Section E has 3 Source-based/Case-based/Passage-based questions carrying
www.cbse.page www.cbse.page
5 marks each.
SECTION A 18´1=18
1. State True or False : 1
“In Python, tuple is a mutable data type”.
S = "text#next"
print(S.strip("t"))
(A) ext#nex (B) ex#nex
(C) text#nex (D) ext#next
91/S 2
www.cbse.page www.cbse
8. Consider the statements given below and then choose the correct output
from the given options : 1
Game="World Cup 2023"
print(Game[-6::-1])
(A) CdrW
www.cbse.page
(B) ce o www.cbse
91/S 3 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
10. Which of the following output will never be obtained when the given code
is executed ? 1
import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
print ("Shuffle", Shuffle, end="#")
print ("Draw", Draw)
(A) Shuffle 1 # Draw 0
(B) Shuffle 10 # Draw 10
(C) Shuffle 10 # Draw 0
www.cbse.page
(D) Shuffle 11 # Draw 50 www.cbse.page
14. Mr. Ravi is creating a field that contains alphanumeric values and fixed
lengths. Which MySQL data type should he choose for the same ? 1
(A) VARCHAR
(B) CHAR
(C) LONG
(D) NUMBER
Questions No.17 and 18 are Assertion and Reason type questions. Each question
consists of two statements, namely, Assertion (A) and Reason (R). Select the most
suitable option considering the Assertion and Reason.
www.cbse.page www.cbse
17. Assertion (A) : Global variables are accessible in the whole program. 1
Reason (R) : Local variables are accessible only within a function or block
in which it is declared.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the
correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the
correct explanation of Assertion (A).
91/S 5 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
18. Assertion (A) : If numeric data are to be written to a text file, the data
needs to be converted into a string before writing to the file. 1
Reason (R) : write() method takes a string as an argument and writes it
to the text file.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the
correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the
correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.
www.cbse.page
SECTION B www.cbse.page
7´2=14
19. (a) (i) Expand the following terms : 1+1=2
URL, XML
20. Observe the following code carefully and rewrite it after removing
all syntactical errors. Underline all the corrections made. 2
def 1func():
a=input("Enter a number"))
www.cbse.page
if a>=33 www.cbse.page
91/S 6
www.cbse.page www.cbse
OR
23. (a) Write the Python statement for each of the following tasks using
BUILT-IN functions/methods only : 1+1=2
(i) To delete an element 10 from the list lst.
(ii) To replace the string "This" with "That" in the string str1.
OR
(b) A dictionary dict2 is copied into the dictionary dict1 such that the
common key’s value gets updated. Write the Python commands to do
the task and after that empty the dictionary dict1. 2
91/S 7 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
24. (a) Mr. Atharva is given a task to create a database, Admin. He has to
create a table, users in the database with the following columns : 1+1=2
User_id – int
User_name – varchar(20)
Password – varchar(10)
Help him by writing SQL queries for both tasks.
OR
return Sum
print(Total(4),end="$")
print(Total(),sep="@")
91/S 8
www.cbse.page www.cbse
SECTION C 5´3=15
26. Predict the output of the Python code given below : 3
s="India Growing"
n = len(s)
m=""
for i in range (0, n) :
if (s[i] >= 'a' and s[i] <= 'm') :
m = m + s [i].upper()
elif (s[i] >= 'O' and s[i] <= 'z') :
m www.cbse.page
= m +s [i-1] www.cbse
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '@'
print (m)
27. Consider the table Stationery given below and write the output of the
SQL queries that follow. 3
Table : Stationery
ITEMNO ITEM DISTRIBUTOR QTY PRICE
401 Ball Pen 0.5 Reliable Stationers 100 16
402 Gel Pen Premium Classic Plastics 150 20
403 www.cbse.page
Eraser Big Clear Deals 210 10 www.cbse
OR
For example :
If the content of the file is :
Had an amazing time at the concert last night with
@MusicLoversCrew.
Excited to announce the launch of our new website!
www.cbse.page www.cbse.page
G20 @ India
Based on the given table, write SQL queries for the following : 3
www.cbse.page www.cbse.page
91/S 10
www.cbse.page www.cbse
Table : GAMES
GCode GameName Type Number PrizeMoney
101 Carrom Board Indoor 2 5000
102 Badminton Outdoor 2 12000
103 Table Tennis Indoor 4 NULL
104 Chess Indoor 2 9000
105 Lawn Tennis Outdoor 4 25000
Table : PLAYERS
PCode Name GCode
1 Nabi Ahmad 101
2 Ravi Sahai
www.cbse.page
108 www.cbse
3 Jatin 101
4 Nazneen 103
Write SQL queries for the following : 4
(i) Display the game type and average number of games played in each
type.
(ii) Display prize money, name of the game, and name of the players from
the tables Games and Players.
(iii) Display the types of games without repetition.
(iv) Display the name of the game and prize money of those games whose
prize money is known.
91/S 11 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
SECTION E 3´5=15
www.cbse.page www.cbse.page
91/S 12
www.cbse.page www.cbse
HR Block 70
Accounts Block 40
Logistics Block 30
(ii) Suggest the best wired medium to efficiently connect various blocks
within the Ambala office compound.
www.cbse.page www.cbse
(iii) Draw an ideal cable layout (Block to Block) for connecting these blocks
for wired connectivity.
(v) Which kind of network will it be between Delhi office and Ambala
office ? 5
91/S 13 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
34. (a) (i) What is the main purpose of seek() and tell() method ?
(ii) Consider a binary file, Cinema.dat containing information in
the following structure :
[Mno, Mname, Mtype]
Write a function, search_copy(), that reads the content from
the file Cinema.dat and copies all the details of the "Comedy"
movie type to file named movie.dat. 5
OR
(b) (i) Give one difference between write() and writeline()
function in text file.
(ii) A Binary file, "Items.dat" has the following structure :
[Icode, Description, Price]
www.cbse.page
Where www.cbse.page
· Password – job
· Host – localhost
Help Sangeeta to write the program in Python for the above
mentioned task. 5
OR
91/S 14
www.cbse.page www.cbse
(b) (i) Give one difference between CHAR and VARCHAR datatype in
MySQL.
(ii) Rahim wants to write a program in Python to insert the
following record in the table named Bank_Account in MySQL
database, Bank :
· Accno – integer
· Cname – string
· Atype – string
· Amount – float
Note the following to establish connectivity between Pythonwww.cbse
www.cbse.page
and MySQL :
· Username – admin
· Password – root
· Host – localhost
The values of fields Accno, Cname, Atype and Amount have
to be accepted from the user. Help Rahim to write the program
in Python. 5
www.cbse.page www.cbse
91/S 15 P.T.O.
www.cbse.page www.cbse
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
Roll No.
www.cbse.page www.cbse.page
$*
General Instructions :
www.cbse.page
This question paper contains five sections, Section A to E.
www.cbse.page
SECTION A
(a) Dictionary
(b) String
(c) List
(d) Tuple
(a) Day.pop()
(b) Day.pop(2)
www.cbse.page www.cbse.page
(c) Day.pop(1)
(d) Day.pop("Tuesday")
(c) NONE
www.cbse.page www.cbse.page
(d) NULL
91 Page 2 of 19
www.cbse.page www.cbse.page
www.cbse.page
(d) ['Amrit', 'Mahotsav', '@', '75'] www.cbse.page
6. Which of the following modes in Python creates a new file, if file does not
exist and overwrites the content, if the file exists ?
(a) r+ (b) r
(c) w (d) a
www.cbse.page
(d) Tuples
(b) UPDATE
(c) INSERT
(d) CREATE
91 Page 4 of 19
www.cbse.page www.cbse.page
www.cbse.page
15. Which of the following functions is a valid built-in function for both list
www.cbse.page
16. fetchone() method fetches only one row in a ResultSet and returns a
__________.
(a) Tuple
(b) List
(c) Dictionary
(d) String
www.cbse.page
Q. 17 and 18 are Assertion (A) and Reasoning (R) based questions. Mark
www.cbse.page
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).
(b) Both (A) and (R) are true and (R) is not the correct explanation for
(A).
18. Assertion (A) : readlines() reads all the lines from a text file and
returns the lines along with newline as a list of strings.
Reasoning (R) :
www.cbse.page
readline() can read the entire text file line bywww.cbse.page
line
without using any looping statements.
SECTION B
20. (a) Write any two differences between Fiber-optic cable and Coaxial
cable. 2
OR
(b) Write one advantage and one disadvantage of wired over wireless
communication. 2
www.cbse.page www.cbse.page
91 Page 6 of 19
www.cbse.page www.cbse.page
print(dict1.values())
24. (a) Write the output of the Python code given below : 2
g=0
def fun1(x,y):
global g
g=x+y
return g
www.cbse.page
def fun2(m,n): www.cbse.page
global g
g=m-n
return g
k=fun1(2,3)
fun2(k,7)
print(g)
OR
91 Page 7 of 19 P.T.O.
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
SECTION C
Table : Sport
ADMNO GAME
1100 CRICKET
1103 FOOTBALL
91 Page 8 of 19
www.cbse.page www.cbse.page
(b) Write the output of the queries (i) to (iv) based on the table,
GARMENT given below : 2
TABLE : GARMENT
GCODE TYPE PRICE FCODE ODR_DATE
G101 EVENING GOWN 850 F03 2008-12-19
G102 SLACKS 750 F02 2020-10-20
G103 FROCK 1000 F01 2021-09-09
G104 TULIP SKIRT 1550 F01 2021-08-10
www.cbse.page
G105 BABY TOP www.cbse.page
1500 F02 2020-03-31
G106 FORMAL PANT 1250 F01 2019-01-06
27. (a) Write a function in Python that displays the book names having
y in their name from a text file Bookname.t 3
Example :
s the names of following books :
www.cbse.page
One Hundred Years of Solitude www.cbse.page
OR
91 Page 9 of 19 P.T.O.
www.cbse.page www.cbse.page
28. Write the output of any three SQL queries (i) to (iv) based on the tables
COMPANY and CUSTOMER given below : 3
Table : COMPANY
CID C_NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY CHENNAI MOBILE
666 DELL
www.cbse.page DELHI LAPTOP www.cbse.page
Table : CUSTOMER
CUSTID CID NAME PRICE QTY
C01 222 ROHIT SHARMA 70000 20
C02 666 DEEPIKA KUMARI 50000 10
C03 111 MOHAN KUMAR 30000 5
C04 555 RADHA MOHAN 30000 11
91 Page 10 of 19
www.cbse.page www.cbse.page
www.cbse.page
List after replacement : www.cbse.page
L = [0,20,30,0,40]
(ii) Pop_element() To pop the object from the stack and display it.
For example :
If the lists of courses details are :
www.cbse.page www.cbse.page
3]
2]
3]
2]
3]
91 Page 11 of 19 P.T.O.
www.cbse.page www.cbse.page
SECTION D
31. ABC Consultants are setting up a secure network for their office campus
at Noida for their day-to-day office and web-based activities. They are
planning to have connectivity between three buildings and the head office
situated in Bengaluru. As a network consultant, give solutions to the
questions (i) to (v), after going through the building locations and www.cbse.page
www.cbse.page other
details which are given below :
BUILDING 3
Building 2 to Building 3 65 m
Noida Branch to Head Office 1500 km
Number of computers
Building Number of Computers
Building 1 25
Building 2 51
Building 3 150
Head Office 10
(i) Suggest the most suitable place to install the server for this
organization. Also, give reason to justify your suggested location. 1
(ii) Suggest the cable layout of connections between the buildings
inside the campus.
www.cbse.page 1
www.cbse.page
91 Page 12 of 19
www.cbse.page www.cbse.page
www.cbse.page
(v) The System Administrator does remote login to any PC, if any
www.cbse.page
requirement arises. Name the protocol, which is used for the same. 1
import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)
print(S[f],S[s],sep=":")
www.cbse.page
Options : www.cbse.page
(I) Pencil:Book
(II) Pencil:Book
Eraser:Bag
(III) Pen:Book
Bag:Book
(IV) Bag:Eraser
91 Page 13 of 19 P.T.O.
www.cbse.page www.cbse.page
mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=__________ # Statement 1
qry= "update Bookshop set Qty=20 where
B_code=105"
___________________ # Statement 2
___________________ # Statement 3
www.cbse.page www.cbse.page
OR
91 Page 14 of 19
www.cbse.page www.cbse.page
ntext=ntext+text[i 1]
else:
ntext=ntext+'&&'
print(ntext)
91 Page 15 of 19 P.T.O.
www.cbse.page www.cbse.page
mydb=mysql.connect(host="localhost",
www.cbse.page user="shop",passwd="Book",database="Bstore")
www.cbse.page
mycursor=___________ # Statement 1
mycursor.execute("_________") # Statement 2
B_Details=__________ # Statement 3
for i in B_Details:
print(i)
33. (a) Write a point of difference between append (a) and write (w)
modes in a text file. 5
Write a program in Python that defines and calls the following
user defined functions :
(i) Add_Teacher() : It accepts the values from the user and
inserts
record consists of a list with field elements as T_id, Tname
www.cbse.page www.cbse.page
and desig to store teacher ID, teacher name and
designation respectively.
(ii) Search_Teacher() : To display the records of all the PGT
(designation) teachers.
OR
(b) Write one point of difference between seek() and tell()
functions in file handling. Write a program in Python that defines
and calls the following user defined functions : 5
(i) Add_Device() : The function accepts and adds records of the
91 Page 16 of 19
www.cbse.page www.cbse.page
SECTION E
Table : Salesperson
S_ID S_NAME AGE S_AMOUNT REGION
S001 SHYAM 35 20000 NORTH
S002 RISHABH 30 25000 EAST
www.cbse.page www.cbse.page
91 Page 17 of 19 P.T.O.
www.cbse.page www.cbse.page
35. Atharva is a programmer, who has recently been given a task to write a
Python code to perform the following binary file operation with the help
of a user defined function/module :
the item whose item_id is 101. The data is stored in the following
format :
{item_id:[item_name,amount]}
def Copy_new():
f1=_____________ # Statement 2
f2=_____________ # Statement 3
item_detail=___________ # Statement 4
if _______________: # Statement 5
pickle.___________ # Statement 6
f1.close()
f2.close()
He has succeeded in writing partial code and has missed out certain
statements. Therefore, as a Python expert, help him to complete the code
91 Page 18 of 19
www.cbse.page www.cbse.page
(ii) Write the correct statement required to open the binary file
"items.dat". (Statement 2) 1
www.cbse.page www.cbse.page
91 Page 19 of 19 P.T.O.
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page www.cbse.page
www.cbse.page
www.cbse.page www.cbse.page