CBSE Class 12 Computer Science Question Paper 2024 (91) with Solutions Skip to content
Smart Notes for Every Exam · instant PDF download after payment +91 92520 37565
Class 12 · Computer Science · Board Paper 2024

CBSE Class 12 Computer Science Question Paper 2024 (91) with Solutions

The complete CBSE Class 12 Computer Science board paper of 2024, Q.P. code 91: all 35 questions exactly as set, with marks. 20 solutions are free below. The Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE) solves all 3 papers in full and sorts every question chapter-wise.

Cover of Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE)
Class 12 Computer Science PYQ book: every chapter + 3 board papers, all solved
US$1.99US$1.9934% off
Free sample

Question paper

Jump to: Question paperSolutions

CBSE Board Paper

2024 · Q.P. Code 91

Time: 3 hours
Maximum marks: 70

Section A: 1 mark each

1.

True or False: While defining a function, the positional parameters in the header must always be written after the default parameters.

1
2.

SELECT combined with ____ clause returns records without repetition. (a) DISTINCT (b) DESCRIBE (c) UNIQUE (d) NULL

1
3.

Output of print(16*5/4*2/5-8): (a) −3.33 (b) 6.0 (c) 0.0 (d) −13.33

1
4.

Possible output? import random / Signal=['RED','YELLOW','GREEN'] / for K in range(2,0,-1): /  R=random.randrange(K) /  print(Signal[R],end='#') (a) YELLOW#RED# (b) RED#GREEN# (c) GREEN#RED# (d) YELLOW#GREEN#

1
5.

The aggregate function which will display the cardinality of a table is ____. (a) sum() (b) count(*) (c) avg() (d) sum(*)

1
6.

Which protocol is used to send and receive emails over a computer network? (a) PPP (b) HTTP (c) FTP (d) SMTP

1
7.

Identify the invalid statement: (a) d = dict() (b) e = {} (c) f = [] (d) g = dict{}

1
8.

myStr = "MISSISSIPPI"; print(myStr[:4]+"#"+myStr[-5:]) (a) MISSI#SIPPI (b) MISS#SIPPI (c) MISS#IPPIS (d) MISSI#IPPIS

1
9.

Which statement will raise an error? (a) print("A"*3) (b) print(5*3) (c) print("15" + 3) (d) print("15" + "13")

1
10.

event="G20 Presidency@2023"; L=event.split(' '); print(L[::-2]) (a) 'G20' (b) ['Presidency@2023'] (c) ['G20'] (d) 'Presidency@2023'

1
11.

Correct unit of measurement for network bandwidth? (a) KB (b) Bit (c) Hz (d) Km

1
12.

a=20 / def convert(a): /  b=20; a=a+b / convert(10) / print(a) (a) 10 (b) 20 (c) 30 (d) Error

1
13.

State True or False: While handling exceptions in Python, name of the exception has to be compulsorily added with except clause.

1
14.

Which is not a DDL command? (a) DROP (b) CREATE (c) UPDATE (d) ALTER

1
15.

Fill in the blank: ____ is a set of rules that needs to be followed by the communicating parties in order to have a successful and reliable data communication over a network.

1
16.

F=open('CONTENT.TXT'). Which is an invalid statement? (a) F.seek(1,0) (b) F.seek(0,1) (c) F.seek(0,-1) (d) F.seek(0,2)

1
17.

A–R. (A): A CSV file is a human readable text file where each line has a number of fields, separated by comma or some other delimiter. (R): writerow() method is used to write a single row in a CSV file.

1
18.

A–R. (A): "Hello".sort() will give an error. (R): sort() does not exist as a method for strings.

1

Section B: 2 marks each

19.

(A)(i) Expand XML and PPP. (ii) One difference between circuit switching and packet switching. OR (B)(i) Define web hosting. (ii) Name any two web browsers.

2
OR

(A)(ii) Give one difference between circuit switching and packet switching.

1
20.

Rewrite after removing syntax and logical errors (underline corrections): def EvenOdd() / for i in range(5): / num=int(input("Enter a number") / if num/2==0: / print("Even") / else: / print("Odd") / EvenOdd()

2
21.

(A) Write showGrades(S); S has Name:[Eng,Math,Science]; display grade: average ≥ 90 → A, ≥ 60 → B, else C. E.g. S={"AMIT":[92,86,64],"NAGMA":[65,42,43],"DAVID":[92,90,88]} → AMIT - B, NAGMA - C, DAVID - A. OR (B) Puzzle(W,N): replace every Nth letter of W with "_" (TELEVISION, 3 → TE_EV_SI_N).

2
22.

Output: LS=["HIMALAYA","NILGIRI","ALASKA","ALPS"]; D={}
for S in LS: if len(S)%4==0: D[S]=len(S)
for K in D: print(K,D[K],sep="#")

2
23.

(A) (i) Remove the item with key "NISHA" from dictionary Students. (ii) Display the number of occurrences of "is" in string message. OR (B) Convert tuple subject to a list and delete its last element.

2
24.

(A) Ms. Veda created table Sports (Game_id, P_Age, G_name); add column Category and insert the record G42, Above 18, Chess, Senior. OR (B) (i) View the list of tables in database Exam. (ii) View the structure of table Term1.

2
25.

Predict the output: def callon(b=20,a=10): /  b=b+a; a=b-a /  print(b,"#",a); return b / x=100; y=200 / x=callon(x,y); print(x,"@",y) / y=callon(y); print(x,"@",y)

2

Section C: 3 marks each

26.

Output: S="Racecar Car Radar"; L=S.split()
for W in L: x=W.upper()
  if x==x[::-1]: for I in x: print(I,end="*")
  else: for I in W: print(I,end="#")
  print()

3
27.

Table ORDERS: (1001 RICE 23 120 2023-09-10), (1002 PULSES 13 120 2023-10-18), (1003 RICE 25 110 2023-11-17), (1004 WHEAT 28 65 2023-12-25), (1005 PULSES 16 110 2024-01-15), (1006 WHEAT 27 55 2024-04-15), (1007 WHEAT 25 60 2024-04-30) [ORDNO ITEM QTY RATE ORDATE]. Output: (i) SELECT ITEM, SUM(QTY) FROM ORDERS GROUP BY ITEM; (ii) SELECT ITEM, QTY FROM ORDERS WHERE ORDATE BETWEEN '2023-11-01' AND '2023-12-31'; (iii) SELECT ORDNO, ORDATE FROM ORDERS WHERE ITEM='WHEAT' AND RATE>=60;

3
28.

(A) Write showInLines() that reads STORY.TXT and displays every sentence in a separate line (a sentence ends with . ? or !). OR (B) Write c_words() that separately counts and displays the number of uppercase and lowercase letters in Words.txt.

3
29.

Table Projects(P_id, Pname, Language, Startdate, Enddate). (i) Add the primary key constraint to P_id. (ii) Change the language to Python of project P002. (iii) Delete table Projects along with its data.

3
30.

List Nums has random integers. Write (i) PushBig(): push all numbers with 5 or more digits from Nums onto stack BigNums; (ii) PopBig(): pop and display the numbers, then display "Stack Empty". Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765].

3

Section D: 4 marks each

31.

Tables Admin(S_id, S_name, Address, S_type) and Transport(S_id, Bus_no, Stop_name). Write SQL: (i) student name and stop name from both tables; (ii) number of students whose S_type is not known; (iii) all details of students whose name starts with 'V'; (iv) student id and address in alphabetical order of student name.

4
32.

Peripheral.csv has [P_id, P_name, Price] (P_id int, P_name str, Price int). Write Add_Device() to accept a record and add it to the file, and Count_Device() to count and display devices with price less than 1000.

4

Section E: 5 marks each

33.

Infotainment Ltd. (Bengaluru) opens a division in Chennai with locations Vajra (120 computers), Trishula (65), Sudershana (75). Distances: Vajra–Trishula 350 m, Trishula–Sudershana 415 m, Sudershana–Vajra 300 m; Bengaluru–Chennai 2000 km (Bengaluru office 250 computers). (i) Suggest and draw the cable layout. (ii) Which block should host the server? (iii) Fast wired medium Bengaluru–Chennai? (iv) Device to connect devices within each location? (v) Device to reduce data loss between locations?

5
34.

(A)(i) (A)(i) Differentiate between 'w' and 'a' file modes.

2
OR

(A)(ii) (A)(ii) Binary file items.dat stores records as {item_id: [item_name, amount]}. Write Copy_new() that copies all records whose amount > 1000 to new_items.dat.

3
OR

(B)(i) (B)(i) What is the advantage of using the with clause while opening a data file? Give its syntax.

2
OR

(B)(ii) (B)(ii) EMP.DAT has records [Emp_Id, Name, Salary]. Write disp_Detail() to display employees whose salary is below 25000.

3
35.

(A)(ii) Sunil wants to update the quantity to 20 of the records whose item code is 111 in table shop (Item_code, Item_name, Qty, Price) of MySQL database Keeper. Username admin, password Shopping, host localhost.
OR (B)(i) Give any two features of SQL. (ii) Sumit wants to display all details from table flight (F_code, F_name, Source, Destination) in database Travel; username root, password airplane, host localhost.

4
OR

(A)(i) (A)(i) Define Cartesian Product with respect to RDBMS.

1

Solutions: CBSE 2024 · 91

Q1

False. It is the reverse: default parameters must come after positional parameters; def f(a=1, b) is a SyntaxError.

Q2
Solution in the PYQ book (US$1.99).
Q3

(c) 0.0. Left to right: 16*5 = 80; 80/4 = 20.0; 20.0*2 = 40.0; 40.0/5 = 8.0; 8.0 − 8 = 0.0 (float, because / gives a float).

Q4
Solution in the PYQ book (US$1.99).
Q5

(b) count(*): it counts all rows; cardinality = number of rows.

Q6
Solution in the PYQ book (US$1.99).
Q7

(d) g = dict{}. dict is a function and must be called with round brackets; dict{} is a SyntaxError.

Q8
Solution in the PYQ book (US$1.99).
Q9

(c). A str cannot be added to an int: TypeError. (a) gives AAA, (b) 15, (d) 1513.

Q10
Solution in the PYQ book (US$1.99).
Q11

(c) Hz. Bandwidth is a range of frequencies; data rate (not bandwidth) is in bits per second.

Q12
Solution in the PYQ book (US$1.99).
Q13

False. A bare except: (without a name) is allowed and catches every exception.

Q14
Solution in the PYQ book (US$1.99).
Q15

Protocol.

Q16
Solution in the PYQ book (US$1.99).
Q17

(b) Both are true, but R (a fact about writing) does not explain why a CSV file is human-readable text.

Q18
Solution in the PYQ book (US$1.99).
Q19

(A)(i) XML: eXtensible Markup Language; PPP: Point-to-Point Protocol. (ii) Circuit switching sets up a dedicated path before sending and sends the whole data along it; packet switching divides data into packets that travel independently and are reassembled (Chapter 8).
(B)(i) Web hosting is a service that allows users to put a website or web page onto the Internet and make it a part of the World Wide Web. (ii) Google Chrome, Microsoft Edge (also Safari, Mozilla Firefox, Opera).

Q19(A)(ii)
Solution in the PYQ book (US$1.99).
Q20

def EvenOdd():                              # 1 colon
for i in range(5):
num = int(input("Enter a number")) # 2 closing )
if num % 2 == 0: # 3 % not /
print("Even")
else:
print("Odd") # 4 indentation
EvenOdd()
(½ mark for each of the four corrections.)

Q21
Solution in the PYQ book (US$1.99).
Q22

Lengths: HIMALAYA 8, NILGIRI 7, ALASKA 6, ALPS 4. Only 8 and 4 are divisible by 4, so D = {'HIMALAYA': 8, 'ALPS': 4}.

HIMALAYA#8
ALPS#4

Q23
Solution in the PYQ book (US$1.99).
Q24

(A) ALTER TABLE Sports ADD Category VARCHAR(10);
INSERT INTO Sports VALUES ('G42', 'Above 18', 'Chess', 'Senior');
(B) (i) USE Exam; SHOW TABLES;
(ii) DESCRIBE Term1; -- or DESC Term1;

Q25
Solution in the PYQ book (US$1.99).
Q26

"RACECAR" is a palindrome → printed in upper case with *. "CAR" is not → original "Car" with #. "RADAR" is a palindrome → *.

R*A*C*E*C*A*R*
C#a#r#
R*A*D*A*R*

Q27
Solution in the PYQ book (US$1.99).
Q28

def showInLines():
with open("STORY.TXT", "r") as F:
S = F.read().replace("\n", " ")
sent = ""
for ch in S:
sent += ch
if ch in ".?!":
print(sent.strip())
sent = ""

Our parents told us that we must eat vegetables to be healthy.
And it turns out, our parents were right!
So, what else did our parents tell?

def c_words():
f = open("Words.txt", "r")
Txt = f.read()
CL = CU = 0
for i in Txt:
if i.islower(): CL += 1
elif i.isupper(): CU += 1
print("Lowercase:", CL, "Uppercase:", CU)
f.close()

Q29
Solution in the PYQ book (US$1.99).
Q30

def PushBig(Nums, BigNums):
for N in Nums:
if len(str(N)) >= 5: # or N >= 10000
BigNums.append(N)

def PopBig(BigNums):
while BigNums:
print(BigNums.pop())
print("Stack Empty")

Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
BigNums = []
PushBig(Nums, BigNums) # [10025, 254923, 1297653, 31498, 92765]
PopBig(BigNums)

92765
31498
1297653
254923
10025
Stack Empty

Q31
Solution in the PYQ book (US$1.99).
Q32

import csv
def Add_Device():
F = open("Peripheral.csv", "a", newline='')
W = csv.writer(F)
P_id = int(input("Enter the Peripheral ID: "))
P_name = input("Enter Peripheral Name: ")
Price = int(input("Enter Price: "))
W.writerow([P_id, P_name, Price])
F.close()

def Count_Device():
F = open("Peripheral.csv", "r")
Count = 0
for D in csv.reader(F):
if int(D[2]) < 1000: # string → int
Count += 1
print(Count)
F.close()

With rows (1,Mouse,450), (2,Monitor,9000), (3,Keyboard,800) the output is 2. Marks: 2 for each function (½ import/open, ½ writer/reader, ½ logic, ½ write/print).

Q33
Solution in the PYQ book (US$1.99).
Q34(A)(i)

'w': opens for writing; creates the file if absent; the pointer is at the beginning, so existing contents are erased. 'a': opens for appending; creates the file if absent; the pointer is at the end, so new data is added after the existing contents.

Q34(A)(ii)
Solution in the PYQ book (US$1.99).
Q34(B)(i)

A file opened with the with clause is closed automatically once control comes out of the with block (even after an exception). Syntax: with open(file_name, access_mode) as file_object: e.g. with open("myfile.txt","r+") as fo: content = fo.read().

Q34(B)(ii)
Solution in the PYQ book (US$1.99).
Q35

import pymysql as pm
DB = pm.connect(host="localhost", user="admin",
passwd="Shopping", database="Keeper")
MyCursor = DB.cursor()
SQL = "UPDATE shop SET Qty = %s WHERE Item_code = %s" % (20, 111)
# or SQL = "UPDATE shop SET Qty = 20 WHERE Item_code = 111"
MyCursor.execute(SQL)
DB.commit()
DB.close()

OR (i) Any two: SQL is the Structured Query Language for relational databases; it is case-insensitive; each statement ends with a semicolon; it has DDL and DML commands; it can retrieve specific data from tables.

import pymysql as pm
DB = pm.connect(host="localhost", user="root",
password="airplane", database="Travel")
MyCursor = DB.cursor()
MyCursor.execute("SELECT * FROM flight")
Rec = MyCursor.fetchall()
for R in Rec:
print(R)
DB.close()

Q35(A)(i)
Solution in the PYQ book (US$1.99).

Get every solution for all 3 papers

  • Every board question of every chapter, each fully solved the way the board gives marks
  • 3 complete board papers, each followed by its solutions
  • Weightage and most-asked topics for every chapter
  • Instant PDF download, colour and black & white print copies
See real pages (free sample)

Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →

What you get in the pack

All chapters in this pack

  1. PYQ Ch 1 Python Revision Tour
  2. PYQ Ch 2 Functions
  3. PYQ Ch 3 Exception Handling
  4. PYQ Ch 4 Text Files
  5. PYQ Ch 5 Binary Files
  6. PYQ Ch 6 CSV Files
  7. PYQ Ch 7 Stack
  8. PYQ Ch 8 Computer Networks I: Evolution and Data Communication
  9. PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
  10. PYQ Ch 10 Network Protocols and Web Services
  11. PYQ Ch 11 Database Concepts
  12. PYQ Ch 12 SQL: DDL, DML and Queries
  13. PYQ Ch 13 SQL: Aggregates, Grouping and Joins
  14. PYQ Ch 14 Interface of Python with MySQL
  15. Board Paper 2026 Set 91 with Solutions
  16. Board Paper 2025 Set 91 with Solutions
  17. Board Paper 2024 Set 91 with Solutions
← Board Paper 2025 Set 91 with Solutions

Prices shown in US dollars. Show prices in: ₹ INR · US$ USD