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.
Question paper
Jump to: Question paperSolutions
2024 · Q.P. Code 91
Maximum marks: 70
Section A: 1 mark each
True or False: While defining a function, the positional parameters in the header must always be written after the default parameters.
SELECT combined with ____ clause returns records without repetition. (a) DISTINCT (b) DESCRIBE (c) UNIQUE (d) NULL
Output of print(16*5/4*2/5-8): (a) −3.33 (b) 6.0 (c) 0.0 (d) −13.33
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#
The aggregate function which will display the cardinality of a table is ____. (a) sum() (b) count(*) (c) avg() (d) sum(*)
Which protocol is used to send and receive emails over a computer network? (a) PPP (b) HTTP (c) FTP (d) SMTP
Identify the invalid statement: (a) d = dict() (b) e = {} (c) f = [] (d) g = dict{}
myStr = "MISSISSIPPI"; print(myStr[:4]+"#"+myStr[-5:]) (a) MISSI#SIPPI (b) MISS#SIPPI (c) MISS#IPPIS (d) MISSI#IPPIS
Which statement will raise an error? (a) print("A"*3) (b) print(5*3) (c) print("15" + 3) (d) print("15" + "13")
event="G20 Presidency@2023"; L=event.split(' '); print(L[::-2]) (a) 'G20' (b) ['Presidency@2023'] (c) ['G20'] (d) 'Presidency@2023'
Correct unit of measurement for network bandwidth? (a) KB (b) Bit (c) Hz (d) Km
a=20 / def convert(a): / b=20; a=a+b / convert(10) / print(a) (a) 10 (b) 20 (c) 30 (d) Error
State True or False: While handling exceptions in Python, name of the exception has to be compulsorily added with except clause.
Which is not a DDL command? (a) DROP (b) CREATE (c) UPDATE (d) ALTER
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.
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)
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.
A–R. (A): "Hello".sort() will give an error. (R): sort() does not exist as a method for strings.
Section B: 2 marks each
(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.
(A)(ii) Give one difference between circuit switching and packet switching.
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()
(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).
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="#")
(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.
(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.
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)
Section C: 3 marks each
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()
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;
(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.
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.
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].
Section D: 4 marks each
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.
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.
Section E: 5 marks each
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?
(A)(i) (A)(i) Differentiate between 'w' and 'a' file modes.
(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.
(B)(i) (B)(i) What is the advantage of using the with clause while opening a data file? Give its syntax.
(B)(ii) (B)(ii) EMP.DAT has records [Emp_Id, Name, Salary]. Write disp_Detail() to display employees whose salary is below 25000.
(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.
(A)(i) (A)(i) Define Cartesian Product with respect to RDBMS.
Solutions: CBSE 2024 · 91
False. It is the reverse: default parameters must come after positional parameters; def f(a=1, b) is a SyntaxError.
(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).
(b) count(*): it counts all rows; cardinality = number of rows.
(d) g = dict{}. dict is a function and must be called with round brackets; dict{} is a SyntaxError.
(c). A str cannot be added to an int: TypeError. (a) gives AAA, (b) 15, (d) 1513.
(c) Hz. Bandwidth is a range of frequencies; data rate (not bandwidth) is in bits per second.
False. A bare except: (without a name) is allowed and catches every exception.
Protocol.
(b) Both are true, but R (a fact about writing) does not explain why a CSV file is human-readable text.
(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).
def EvenOdd(): # 1 colon(½ mark for each of the four corrections.)
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()
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
(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;
"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*
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()
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
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).
'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.
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().
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()
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
Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →
What you get in the pack
- CBSE Class 12 Computer Science board papers 2024 to 2026 (3 full board papers)
- All 14 chapters and 3 board papers complete
- Part A: all 14 chapters, questions sorted chapter-wise and by marks
- Year-wise weightage table and most-asked topics for every chapter
- Part B: each full board paper followed by its complete solutions
- Full programs; every output traced and verified by running the code
- Only the current syllabus in Part A
All chapters in this pack
- PYQ Ch 1 Python Revision Tour
- PYQ Ch 2 Functions
- PYQ Ch 3 Exception Handling
- PYQ Ch 4 Text Files
- PYQ Ch 5 Binary Files
- PYQ Ch 6 CSV Files
- PYQ Ch 7 Stack
- PYQ Ch 8 Computer Networks I: Evolution and Data Communication
- PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
- PYQ Ch 10 Network Protocols and Web Services
- PYQ Ch 11 Database Concepts
- PYQ Ch 12 SQL: DDL, DML and Queries
- PYQ Ch 13 SQL: Aggregates, Grouping and Joins
- PYQ Ch 14 Interface of Python with MySQL
- Board Paper 2026 Set 91 with Solutions
- Board Paper 2025 Set 91 with Solutions
- Board Paper 2024 Set 91 with Solutions
