Skip to content
← Computer Science

Computer Science · Class 12 Optional

CBSE Class 12 Computer Science — Real Previous-Year Papers

with complete answers

Real previous-year board papers, year by year — the official exam pattern, the full question paper, and every question solved the concept-first way. Distinct from the chapter-wise textbook bank.

2019–2026
Years of papers
8
Total Papers
8
Real Board Papers
0
Sample papers
277
Real-paper Q & A
0
Sample-paper Q & A

Real board-paper questions available, by year

37 Q2026complete
37 Q2025complete
35 Q2024complete
70 Q20232 sets
13 Q2022COVID Term-2 · 1 sets
—2021Not available
39 Q2020complete
46 Q2019complete

Shown as extracted / official per paper (38 from 2023, 36 earlier). Years with multiple CBSE series sets show total questions across all sets (each set is a full paper); some counts read higher because OR-choices & case-study sub-parts are counted separately.

CBSE Class XII Board 2026 · Set 91/4

Real board examination

About this paper

The real Class-12 board examination held in 2026. Every question below is solved the concept-first way. Sample papers are labelled honestly — never shown as a past exam.

Total marks
70
Questions
37
Duration
180 min
Sections
5

The marks / questions / duration above are the official exam pattern. We currently have 37 of this paper’s questions (100% of the full paper), with 37 fully solved. Questions we couldn’t yet extract or verify are held — never shown as complete.

Sections & marks

SectionTypeQuestionsMarks eachTotal
ASection AObjective (MCQ / True-False / 1-mark)21121
BSection BVery short answer7214
CSection CShort answer339
DSection DLong answer4416
ESection ELong answer2510
Total3770

The question paper

The questions we hold for this paper, laid out by section. Solutions are on the Answers tab.

Board Examination

Computer Science

CBSE Class XII Board 2026 · Set 91/4

Series/Set: 91/4Roll No. ________
Time Allowed: 3 hoursMaximum Marks: 70

General Instructions

  1. This question paper contains 37 questions divided into 5 sections — A, B, C, D, E.
  2. Section A comprises 21 questions of 1 mark each (Objective (MCQ / True-False / 1-mark)).
  3. Section B comprises 7 questions of 2 marks each (Very short answer).
  4. Section C comprises 3 questions of 3 marks each (Short answer).
  5. Section D comprises 4 questions of 4 marks each (Long answer).
  6. Section E comprises 2 questions of 5 marks each (Long answer).

Above is the official exam pattern. The questions printed below are those we currently hold for this paper.

Section A

Objective (MCQ / True-False / 1-mark) · 1 mark each · 21 of 21 shown

Q1.
State True or False : In Python, data type of 74 is same as the data type of 74.0.
[1]
Q2.
Identify the output of the following code snippet : s = "the Truth" print(s.capitalize()) (A) The truth (B) THE TRUTH (C) The Truth (D) the Truth
[1]
Q3.
Which of the following expressions in Python evaluates to True ? (A) 2>3 and 2<3 (B) 3>1 and 2 (C) 3>1 and 3>2 (D) 3>1 and 3<2
[1]
Q4.
What is the output of the following code snippet ? s='War and Peace by Leo Tolstoy' print(s.partition("by")) (A) ('War and Peace ', 'by', ' Leo Tolstoy') (B) ['War and Peace ', 'by', ' Leo Tolstoy'] (C) ('War and Peace ', ' Leo Tolstoy') (D) ['War and Peace ', ' Leo Tolstoy']
[1]
Q5.
What will be the output of the following statement ? print("PythonProgram"[-1:2:-2])
[1]
Q6.
What will be the output of the following code snippet ? t = tuple('tuple') t2 = t[2], t += t2 print(t) (A) ('tuple') (B) ('tuple','p') (C) ('t', 'u', 'p', 'l', 'e', 'p') (D) ('t', 'u', 'p', 'l', 'e')
[1]
Page 1 of 7
Q7.
Which of the following statements is true about dictionaries in Python ? (A) A dictionary is an example of sequence datatype. (B) A dictionary cannot have two elements with same key. (C) A dictionary cannot have two elements with same value. (D) The key and value of an element cannot be the same.
[1]
Q8.
If L is a list with 6 elements, then which of the following statements will raise an exception ? (A) L.pop(1) (B) L.pop(6) (C) L.insert(1,6) (D) L.insert(6,1)
[1]
Q9.
What will be the output of the following code ? def f1(a,b=1): print(a+b,end='-') c=f1(1,2) print(c,sep='*') (A) 3-2 (B) 3-2* (C) 3-None (D) 3*None-
[1]
Q10.
Consider the statement given below : f1 = open("pqr.dat","____") Which of the following is the correct file mode to open the file in read only mode ? (A) a (B) rb (C) r+ (D) rb+
[1]
Q11.
State whether the following statement is True or False : In Python, Logical errors can be handled using try……except……finally statement.
[1]
Q12.
A table has two candidate keys, one of which is chosen as the primary key. How many alternate keys does this table have ? (A) 0 (B) 1 (C) 2 (D) 3
[1]
Q13.
Which of the following SQL command can change the degree of the existing relation ? (A) DROP TABLE (B) ALTER TABLE (C) UPDATE…SET (D) DELETE
[1]
Q14.
What will be the output of the query ? SELECT MACHINEID, MACHINENAME FROM INVENTORY WHERE QUANTITY <= 100; (A) All columns of INVENTORY table with quantity greater than 100 (B) ID and name of machines with quantity less than 100 from INVENTORY table (C) All columns of INVENTORY table with quantity greater than or equal to 100 (D) ID and name of machines with quantity less than or equal to 100 from INVENTORY table.
[1]
Q15.
A relation in MySQL database consists of 2 tuples and 3 attributes. If 2 attributes are deleted and 4 tuples are added, what will be the cardinality of the relation ? (A) 4 (B) 5 (C) 6 (D) 7
[1]
Q16.
Which aggregate function in SQL returns the smallest value from a column in a table ? (A) MIN() (B) MAX() (C) SMALL() (D) LOWER()
[1]
Page 2 of 7
Q17.
With respect to computer networks, which of the following is the correct expanded form of RJ 45 ? (A) Radio Jockey 45 (B) Registered Jockey 45 (C) Radio Jack 45 (D) Registered Jack 45
[1]
Q18.
Which network device serves as the entry and exit point of a network, as all data coming in or going out of a network must first pass through it in order to use routing paths ? (A) Modem (B) Gateway (C) Switch (D) Repeater
[1]
Q19.
Expand the term XML.
[1]
Q20.
Q. Nos. 20 and 21 are Assertion (A) and Reason (R) based questions. Mark the correct choice as : (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A). (B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A). (C) Assertion (A) is true, but Reason (R) is false. (D) Assertion (A) is false, but Reason (R) is true. Assertion (A) : [1,2,3]+'123' is an invalid expression in Python. Reason (R) : In Python, a list cannot be concatenated with a string.
[1]
Q21.
Assertion (A) : The PRIMARY KEY constraint in SQL ensures that each value in the column(s) is unique and cannot be NULL. Reason (R) : Candidate keys are not eligible to become a primary key. (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A). (B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A). (C) Assertion (A) is true, but Reason (R) is false. (D) Assertion (A) is false, but Reason (R) is true.
[1]
Section B

Very short answer · 2 marks each · 7 of 7 shown

Q1.
What is the difference between default parameters and positional parameters in Python ? Also give an example of a function header which uses both.
[2]
Q2.
Write a Python statement to perform the following tasks : (USE BUILTIN FUNCTIONS / METHODS ONLY) (i) To create a new list L1 containing the elements of list L arranged in ascending order, without modifying list L. (ii) A statement to check whether the given character, ch is an alphabet or a number.
[2]
Page 3 of 7
Q3.
Assuming that D1 is a dictionary in Python, (i) (a) Write a Python expression to check if the key, 'RNo' is present in D1. OR (b) Write a Python expression to check if any key in D1 has a value 12. (ii) (a) Write a single statement using a BUILTIN function to add the key : value pair 'RNo' : 12, if the key 'RNo' is not present in D1. However, if the key 'RNo' is present, the function should return its value. OR (b) Write a single statement to delete all the elements from D1.
[2]
Q4.
What possible output(s) from the given options will NOT be displayed when the following code is executed ? Also, mention, for how many iterations the for loop in the given code will run ? import random a = [1,2,3,4,5,6] for i in range(4): j = random.randrange(i,5) print(a[j],end='-') print() Options : (A) 3-4-5-4- (B) 2-2-4-5- (C) 4-3-3-5- (D) 5-1-2-4-
[2]
Q5.
The function given below is written to accept a string s as a parameter and return the number of vowels appearing in the string. The code has certain errors. Observe the code carefully and rewrite it after removing all the logical and syntax errors. Underline all the corrections made. def CountVowels(s): c=0 for ch in range(s): if 'aeiouAEIOU' in ch: c=+1 return(ch)
[2]
Q6.
Ms. Zoya is a Production Manager in a factory which packages mineral water. She decides to create a table in a database to keep track of the stock present in the factory. Each record of the table will have the following fields : WCode – Code of the item (type – CHAR(5)) WDescription – Description of the item (type – VARCHAR(20)) BQty – Balance quantity of the item (type – INTEGER) UPrice – Unit Price of the item (type – FLOAT) The name of the table is WSTOCK. (i) (a) Write an SQL command to create the above table (WCode should be the primary key). OR (b) Can UPrice be the primary key of the above table ? Justify your answer. (ii) (a) Assuming that the table WSTOCK is already created, write an SQL command to add an attribute EDate (of DATE type) to the table. OR (b) Assuming that the table WSTOCK is already created, write an SQL command to remove the column BQty from the table.
[2]
Q7.
(a) List one advantage and one disadvantage of Bus topology. OR (b) What is protocol in the context of computer networks ? Which protocol is used to transmit hypertext across the web ?
[2]
Section C

Short answer · 3 marks each · 3 of 3 shown

Q1.
(a) Write a Python function that counts and returns the number of digits appearing in the text file "Space.txt". For example, if the file contains : Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity’s cosmic journey continues! Then the function should return 11. OR (b) Write a Python function that displays the words in which the lowercase letter 'e' appears at least twice in the text file 'Space.txt'. For example, if the file contains : Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity’s cosmic journey continues! Then the function should display : incredible advancements science. agencies serves research.
[3]
Page 4 of 7
Q2.
(a) A stack named FruitStack, implemented using list, contains records of some fruits. Each record is represented as a dictionary with keys ‘Name’, ‘Origin’, ‘Price’, and ‘Expiry’. A sample record is given here : 'Name':'Apple','Origin':'France','Price':120, 'Expiry':'12-08-2025' Write the following user-defined functions in Python to perform the specified operations on FruitStack : (i) pushfruit(FruitStack, Fruit): This function takes the stack FruitStack and a new record Fruit as arguments and pushes the record stored in Fruit onto FruitStack if the Price is less than 100. (ii) popfruit(FruitStack): This function pops the topmost record from the stack and returns it. If the stack is already empty, the function should display “UNDERFLOW”. (iii) display(FruitStack): This function displays all the elements of the stack starting from the topmost element. If the stack is empty, the function should display ‘EMPTY STACK’. OR (b) Write a Python program to accept 10 integers from the user. If the entered number is a three-digit even integer, push it onto a stack. After all inputs are taken, pop all the three-digit even integers from the stack and display them. For example, if the user enters 12, 31, 320, 457, 6, 92, 924, 220, 1, 218, then the stack should contain : 320, 924, 220, 218 and the output of the program should be : 218 220 924 320
[3]
Q3.
(a) Write the output of the following code : def Exam2026(given) : new=[] for ch in given[1:-1]: if ch.isupper(): new.reverse() elif ch not in new: new.append(ch) elif ch in new: new.pop() print(new) Exam2026("Gold-24Medals") OR (b) Write the output of the following code : def Exam2026(given): new = 0 while given: if new % 2: new += given % 10 else: new += given % 5 print(new, end='-') given //= 10 Exam2026(123456)
[3]
Section D

Long answer · 4 marks each · 4 of 4 shown

Q1.
Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his shop. After creating the table, he entered the data and the table looked as follows : Code Type Volume Qty Price AF0.5 F 0.5 300 38.00 MF0.5 F 0.5 250 36.50 MT1.0 T 1.0 150 64.00 AT1.0 T 1.0 100 66.00 PD1.0 D 1.0 50 52.00 PT0.5 T 0.5 78 30.00 (a) Based on the data given above, write the SQL queries for the following tasks : (i) To display Type and the maximum Price for each Type of milk. (ii) For each record, increase the Price by 0.5 where Type is 'F'. (iii) To display the total value of the stock (total of Qty * Price). (iv) To display the details of all records where Code starts with 'A'. OR (b) Considering the table STOCK as given above, write the output on execution of the following queries : (i) SELECT Volume, Qty, Price FROM STOCK WHERE Type IN ('F','D'); (ii) SELECT Code, Qty FROM STOCK WHERE Price BETWEEN 30 AND 50; (iii) SELECT DISTINCT Type FROM STOCK; (iv) SELECT Volume, count(*) FROM STOCK GROUP BY Volume;
[4]
Q2.
A csv file "States.csv" contains some data about all the states of India. Each record of the file contains the following data : - Name of the State - Capital of the State - Population of the State - Official Language of the State For example, a sample record in the file is : ['Andhra Pradesh','Amaravati',52221000,'Telugu'] Write a Python program which reads the data from this file and appends all those records where population is more than 10000000 into another csv file 'More.csv'. Note : "States.csv" also contains the Header row. The Header row should NOT be copied to "More.csv".
[4]
Page 5 of 7
Q3.
Assume that you are the Manager of the Loans department of a Finance House. To keep track of the loans you have created two tables : CUSTOMERS and LOANS. The sample data in these tables is given below : Table : CUSTOMERS CID CName Phone 00001 Raj Malhotra 1234567890 00003 David Xavier 3456789012 00004 Damini Iyer 3156789012 00008 Abdul 2345678901 Table : LOANS SNo CID LAmt LDate Terms RoI 1 00003 200000 2025-12-06 60 7.80 2 00008 2500000 2023-08-09 60 9.00 3 00001 500000 2025-08-13 48 6.00 4 00003 300000 2026-12-07 36 8.00 5 00004 600000 2026-12-07 60 6.00 Note : The tables may contain more records than shown here. The management of the Finance House needs certain reports from you. Write the queries to extract the following data to create the reports : (i) Number of records from LOANS table where Rate of Interest (RoI) is above 7.0. (ii) Names of the customers whose loan amount (LAmt) is above 1000000. (iii) CID, CName and Terms of all those records where Loan Date (LDate) is after 31st December, 2024. (iv) (a) Details of all the loans in the descending order of RoI. OR (b) CID and average term for each CID from the LOANS table.
[4]
Q4.
Peter has created a table named Account in MySQL database, SCHOOL, having following structure : Studᵢd – integer Sname – string Class – string Fees – float Help him in writing a Python program to display records of those students whose fees is less than 5000. Note the following to establish connectivity between Python and MySQL : Username – admin Password – root Host – localhost
[4]
Section E

Long answer · 5 marks each · 2 of 2 shown

Q1.
NextStep is an organization which has a pool of resource persons to conduct training workshops on various topics related to ICT. The data of all its Resource Persons is stored in a binary file RESOURCES.DAT using the following record structure (each record is a tuple) : (RID, RName, RExpertise, Charges) where : RID – Resource Person’s ID (An integer) RName – Resource Person’s Name (A string) RExpertise – Area of expertise of the Resource Person Charges – Charges (in rupees) per hour to conduct a workshop For example, a record in the file is : (12, 'P. Velusami','Machine Learning',5000) In this context, write the following user defined functions in Python : (i) Append() – To input the data of a Resource Person and write it in the file RESOURCES.DAT. (ii) Update() – To increase the Charges of each resource person by 500.
[5]
Page 6 of 7
Q2.
Sanjeevani is a big group of educational institutions with its head office in Hyderabad. It is planning to set up a new University in Amritsar. The Amritsar University Campus will have four blocks/buildings – ADMIN, ACADEMIC, HOSTEL, SPORTS. You, as a network expert, need to suggest the best network-related solutions for them to resolve the issues/problems mentioned in points (i) to (v), keeping in mind the distances between various blocks / buildings and other given parameters. Block to Block distances (in Mtrs.) FROM TO DISTANCE ADMIN ACADEMIC 60 M ADMIN HOSTEL 160 M ADMIN SPORTS 80 M ACADEMIC HOSTEL 40 M ACADEMIC SPORTS 120 M HOSTEL SPORTS 150 M Distance of Hyderabad Head Office from Amritsar University Campus = 2000 km. Number of computers in each block is as follows : ADMIN 25 ACADEMIC 600 HOSTEL 120 SPORTS 50 (i) Suggest the most appropriate location of the server inside the Amritsar University Campus. Justify your choice. (ii) Draw the cable layout to efficiently connect various blocks within the Amritsar University Campus. (iii) Name any two wired media that can be used to connect various computers of a block inside Amritsar Campus. (iv) For the academic purpose, the University will provide its own 24 x 7 FM channel within the University Campus. Which communication medium, out of the following, is used by FM ? (A) Radio Waves (B) Micro Waves (C) Infrared Waves (v) (a) The students will be attending a lot of online academic sessions and workshops. These will involve audio-visual communication. Write the full name of the protocol which will be used for such a communication through the internet. OR (b) Where should a repeater be installed in Amritsar University campus to boost the signal between blocks ? Justify your answer.
[5]
Page 7 of 7