Sample Question Papers for Class 12 Computer Science
Access comprehensive sample question papers for Class 12 Computer Science using the CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download. Designed to align with the 2026-27 CBSE academic guidelines, these model papers help students assess their exam readiness and understand current marking schemes.
Practice Class 12 Computer Science Exam Papers
View or download the dedicated CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download resource below. Engaging with these sample papers under timed conditions ensures continuous academic progress and mastery of the 2026-27 exam format.
Section-A (21 x 1 = 21 Marks)
1. Write the output on execution of the following Python code:
L1=[10,20,25,30]
L1.insert(1,15)
print(L1) [1 Mark]
Answer: [10, 15, 20, 25, 30]
Teacher's Note:
a) insert(1,15) places 15 at index 1 and shifts the other elements one place to the right.
b) insert() does not replace the element at that index; it adds a new element.
2. What will be the output of the following expression?
Msg = "programming is amazing"
print(Msg.split("m")) [1 Mark]
a) ['progra', '', 'ing is a', 'azing']
b) ['progra', 'ming is a', 'azing']
c) ('progra', '', 'ing is amazing')
d) ['program', 'ing is a', 'zing']
Answer: a) ['progra', '', 'ing is a', 'azing']
Teacher's Note:
a) The two "m" letters next to each other in "programming" give an empty string '' between them.
b) split() always returns a list, so option (c), which is a tuple, is wrong.
3. Which of the following data types in Python is mutable? [1 Mark]
a) Tuple
b) String
c) Integer
d) List
Answer: d) List
Teacher's Note:
a) A list can be changed in place, for example with append() or by assigning to an index.
b) Tuples, strings and integers are immutable.
4. A column in one table matching a primary key of another table is called a: [1 Mark]
a) Composite key
b) Candidate key
c) Foreign key
d) Super key
Answer: c) Foreign key
Teacher's Note:
a) A foreign key links two tables by referring to the primary key of the other table.
b) A composite key is a key made of two or more columns of the same table.
5. Consider the following Python code:
t = (1, 2, 3)
l = [4, 5]
print(t + l)
What will happen when this code is executed? [1 Mark]
a) [1, 2, 3, 4, 5]
b) (1, 2, 3, 4, 5)
c) Error, because a tuple cannot be concatenated with a list
d) ((1, 2, 3), [4, 5])
Answer: c) Error, because a tuple cannot be concatenated with a list
Teacher's Note:
a) The + operator joins only sequences of the same type, so Python raises a TypeError.
b) t + tuple(l) would give (1, 2, 3, 4, 5).
6. What possible output is expected to be displayed on the screen at the time of execution of the Python program from the following code?
import random
games = {0: "Chess",1: "Scrabble",2: "Sudoku",3: "Tic-Tac-Toe",4: "Puzzle"
}
start_key = random.randint(1, 2)
end_key = random.randrange(3, 4)
for k in range(start_key, end_key + 1):
print(games[k], end="@@") [1 Mark]
a) Sudoku@@Tic-Tac-Toe@@Puzzle@@
b) Scrabble@@Sudoku@@Tic-Tac-Toe@@
c) Chess@@Scrabble@@Tic-Tac-Toe@@
d) Scrabble@@Tic-Tac-Toe@@
Answer: b) Scrabble@@Sudoku@@Tic-Tac-Toe@@
Teacher's Note:
a) randint(1, 2) gives 1 or 2, and randrange(3, 4) always gives 3, so k runs from start_key to 3.
b) With start_key = 1 the keys printed are 1, 2, 3, which gives option (b).
c) Puzzle (key 4) and Chess (key 0) can never be printed, and keys cannot be skipped.
7. Predict the output for the following:
Dl={"Pen":12, "Pencil":6, "Scale":5, "InkPen":20}
print(12 in Dl) [1 Mark]
a) False
b) Error
c) None
d) True
Answer: a) False
Teacher's Note:
a) The in operator on a dictionary checks only the keys, not the values.
b) 12 is a value, not a key, so the result is False; 12 in Dl.values() would give True.
8. Long-distance communication without line-of-sight is mainly achieved using: [1 Mark]
a) Microwaves
b) Ultraviolet
c) Radio waves
d) X-rays
Answer: c) Radio waves
Teacher's Note:
a) Radio waves can travel long distances and do not need a line-of-sight path.
b) Microwaves need the sending and receiving antennas to be in line of sight.
9. Which MySQL query will display all employees whose salaries are between 90,000 and 100,000 (including limits)? [1 Mark]
a) SELECT * FROM Employees WHERE salary > 90000 AND salary < 100000;
b) SELECT * FROM Employees WHERE salary IN (90000, 100000);
c) SELECT * FROM Employees WHERE salary BETWEEN 90000 AND 100000;
d) SELECT * FROM Employees WHERE salary = 90000 OR salary = 100000;
Answer: c) SELECT * FROM Employees WHERE salary BETWEEN 90000 AND 100000;
Teacher's Note:
a) BETWEEN includes both the lower and the upper limits.
b) Option (a) leaves out the limits, and options (b) and (d) match only the two exact values.
10. What will be the output of the following Python statement:
print(25+100**1**3/5) [1 Mark]
Answer: 45.0
Teacher's Note:
a) ** is evaluated from right to left: 1**3 = 1, so 100**1 = 100.
b) Then 100/5 = 20.0 and 25 + 20.0 = 45.0.
c) The / operator always gives a float, so write 45.0, not 45.
11. What is the data type of the result when the expression 5 // 2 is evaluated in Python? [1 Mark]
a) float
b) int
c) string
d) None
Answer: b) int
Teacher's Note:
a) // is floor division; with two integers it gives an integer, here 2.
b) If either operand is a float (for example 5.0 // 2), the result is a float.
12. Every network interface card (NIC) comes with its own ________ address. [1 Mark]
a) Internet Protocol (IP)
b) Open Systems Interconnection (OSI)
c) Physical (MAC)
d) Dynamic Host Configuration Protocol (DHCP)
Answer: c) Physical (MAC)
Teacher's Note:
a) The MAC (Media Access Control) address is fixed on the NIC by the manufacturer.
b) An IP address is assigned to a device on a network and can change.
13. In a student table, "Class" can only take values from {IX, X, XI, XII}. This set is called the ________. [1 Mark]
a) Domain
b) Tuple
c) Attribute
d) Key
Answer: a) Domain
Teacher's Note:
a) A domain is the set of all allowed values for an attribute.
b) An attribute is the column itself, and a tuple is a row.
14. What would be written in the file errorlog.txt after the following code is run?
def data(num):
try:
return 190/(29-num)
except ZeroDivisionError:
logfile = open ("errorlog.txt", "w")
logfile.write ("Num was 29")
logfile.close()
data(29) [1 Mark]
Answer: Num was 29
Teacher's Note:
a) With num = 29, 29 - num = 0, so 190/0 raises ZeroDivisionError.
b) The except block runs and writes "Num was 29" into the file.
15. Which of the following will NOT change if you insert a new record into a table? [1 Mark]
a) Cardinality
b) Degree
c) Number of tuples
d) Total rows
Answer: b) Degree
Teacher's Note:
a) Degree is the number of columns (attributes), and inserting a row does not add a column.
b) Cardinality, number of tuples and total rows all mean the number of rows, so they increase by 1.
16. What will be the output of the following Python code?
y=8
def update():
y=y+2
print(y)
update() [1 Mark]
a) 10
b) 8
c) Error
d) None
Answer: c) Error
Teacher's Note:
a) Because y is assigned inside update(), Python treats y as a local variable of the function.
b) The local y is used before it gets a value, so Python raises UnboundLocalError.
c) Writing global y as the first line of the function would print 10.
17. In ________ switching, before a communication starts, a dedicated path is identified between the sender and the receiver. [1 Mark]
a) Graph
b) Plot
c) Circuit
d) Packet
Answer: c) Circuit
Teacher's Note:
a) In circuit switching a dedicated path is set up first, as in a telephone call.
b) In packet switching there is no dedicated path; packets may take different routes.
18. What will be the output of the following Python code?
text = "Drone Expo"
print(text[-2: :-4]) [1 Mark]
Answer: peD
Teacher's Note:
a) Index -2 is 'p'; a step of -4 moves backwards 4 places each time.
b) The characters picked are at indexes 8 ('p'), 4 ('e') and 0 ('D'), giving peD.
19. Which MySQL command correctly removes an attribute Age from table Student? [1 Mark]
a) ALTER TABLE Student DROP COLUMN Age;
b) ALTER TABLE Student REMOVE Age;
c) DROP COLUMN Age FROM Student;
d) DELETE COLUMN Age FROM Student;
Answer: a) ALTER TABLE Student DROP COLUMN Age;
Teacher's Note:
a) Removing a column changes the structure of the table, so ALTER TABLE is used.
b) DELETE removes rows, not columns.
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark the correct choice as:
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.
c) A is True but R is False.
d) A is False but R is True.
20. Assertion (A): Opening a file in mode rb allows you to read a binary file without modifying it.
Reason (R): In rb mode, if the file does not exist, Python creates a new empty file. [1 Mark]
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.
c) A is True but R is False.
d) A is False but R is True.
Answer: c) A is True but R is False.
Teacher's Note:
a) rb mode opens a binary file for reading only, so the file is not modified.
b) If the file does not exist, rb mode raises FileNotFoundError; it does not create a new file.
21. Assertion (A): The MySQL query SELECT Student_Name FROM Student WHERE Guardian_Phone IS NULL; displays the names of students whose guardian phone number is not recorded.
Reason (R): In MySQL, you can also use = to check for NULL values; it is equivalent to IS NULL to identify columns with no value. [1 Mark]
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.
c) A is True but R is False.
d) A is False but R is True.
Answer: c) A is True but R is False.
Teacher's Note:
a) IS NULL correctly finds the rows where no value is stored.
b) A condition like Guardian_Phone = NULL never becomes true, so = cannot be used to check for NULL.
Section-B ( 7 x 2=14 Marks)
22. A. Define global variable and local variable with a suitable example. [2 Marks]
Answer:
Global variable: It is defined outside a function and can be accessed anywhere in the program.
x = 10 # global
print(x)
Local variable: It is defined inside a function and can be accessed only inside that function.
def demo():
y = 5 # local
print(y)
Teacher's Note:
a) 1 mark is for the correct difference and half a mark for each example.
b) Keywords: "outside a function, accessible anywhere" and "inside a function, accessible only there".
c) Using y outside demo() would give a NameError, which shows that y is local.
OR
B. Write the difference between the seek() and tell() methods in Python text file handling with a suitable example. [2 Marks]
Answer:
tell(): It returns the current position of the file pointer in the file.
f = open("file.txt", "r")
print(f.tell()) # e.g.,0
seek(offset): It moves the file pointer to a specified position in the file.
f.seek(5) # moves pointer to 5th byte
Teacher's Note:
a) tell() only reports the position, while seek() changes the position.
b) 1 mark is for the difference and half a mark for each example.
c) Just after opening a file in "r" mode, tell() returns 0.
23. The Python program below tries to print the list in reverse. However, there are syntax and logical errors in the code.
Rewrite it after removing all the errors. Also, underline all the corrections made
words=["Class Test","Term Exams","Pre-board Exam","Board Exam’]
L=len(words)
for i in range(L, -1, -1)
Print (words[i] , end = " ") [2 Marks]
Answer:
words=["Class Test","Term Exams","Pre-board Exam","Board Exam"]
L=len(words)
for i in range(L-1, -1, -1):
print (words[i] , end = " ")
Teacher's Note:
a) The four corrections are: matching double quote after "Board Exam", L-1 in range(), colon after the for statement, and print in lowercase.
b) The last index of a list is L-1, so range(L, ...) would give an IndexError; this is the logical error.
c) Half a mark is given for each of the 4 corrections, so underline every one.
24. A. Write a Python function capitalize_words(words) that takes a list of strings words and returns a new list with each word capitalize.
Example:
If the input is ["python", "computer", "science"]
The output should be ["Python", "Computer", "Science"]. [2 Marks]
Answer:
def capitalize_words(words): #words is a list of strings
result = [ ]
for w in words:
result.append(w.capitalize())
print(result)
Teacher's Note:
a) Marks: half a mark for the function definition, 1 mark for the logic and half a mark for the print statement.
b) capitalize() makes the first letter uppercase and the rest lowercase.
c) Since the question says "returns a new list", you may also write return result in place of print(result) and print the returned list when calling the function.
OR
B. Write a Python function sum_positive(list1) that takes a list of numbers and prints the sum of all positive numbers in the list.
Example:
If the input is [10, -5, 20, -3, 7]
The output should be 37. [2 Marks]
Answer:
def sum_positive(list1): #list1 is a list of numbers
total = 0
for num in list1:
if num > 0:
total += num
print(total)
Teacher's Note:
a) Marks: half a mark for the function definition, 1 mark for the logic and half a mark for the print statement.
b) Check: 10 + 20 + 7 = 37.
c) Initialise total = 0 before the loop, not inside it.
25. A. (Answer using Python built-in methods/functions only):
I. Write a statement to check whether the string username starts with "admin".
II. Given data = [2, 7, 9, 9, 2], write a statement to count how many times the largest element occurs. [2 Marks]
Answer:
I. username.startswith("admin")
II. data.count(max(data))
Teacher's Note:
a) startswith() returns True or False.
b) max(data) gives 9 and count(9) gives 2.
c) Each part carries 1 mark.
OR
B. Predict the output of the following Python code:
text = "Python Programming"
print(text.replace("o", "0"))
print(text.find("z")) [2 Marks]
Answer:
Pyth0n Pr0gramming
-1
Teacher's Note:
a) replace() changes every lowercase letter "o" to the digit "0".
b) find() returns -1 when the substring is not found.
c) Each output line carries 1 mark.
26. Predict the output of the following Python code:
code = "gLaD5"
result = []
i = 0
while i < len(code):
if code[i].isupper():
result.append(code[i].lower())
elif code[i].isdigit():
result.append(int(code[i]) * 2)
else:
result.append("#")
i += 1
print(result) [2 Marks]
Answer: ['#', 'l', '#', 'd', 10]
Teacher's Note:
a) Lowercase letters g and a give '#'; uppercase L and D are changed to 'l' and 'd'.
b) The digit 5 becomes the integer 10, so it is printed without quotes.
27. A. Write suitable commands to do the following in MySQL.
I. Display a list of all the relations stored in a database.
II. Delete a database named CS_SP. [2 Marks]
Answer:
I. Show tables;
II. Drop database CS_SP;
Teacher's Note:
a) Relations are tables, so SHOW TABLES lists them.
b) DROP DATABASE deletes the whole database with all its tables.
c) Each command carries 1 mark.
OR
B. Differentiate between alter and update command in MySQL with a suitable example. [2 Marks]
Answer:
1. ALTER: It is used to change the structure of a table. It adds, deletes or modifies columns or constraints.
Ex: ALTER TABLE Employee ADD age INT;
2. UPDATE: It is used to modify the data stored in the table. It changes the values in rows.
Ex: UPDATE Employee SET salary = 50000 WHERE emp_id = 10;
Teacher's Note:
a) ALTER is a DDL command (structure) and UPDATE is a DML command (data).
b) 1 mark is for the difference and half a mark for each example.
28. A. Which protocol helps us to browse through web pages using internet browsers? Name any one internet browser. [2 Marks]
Answer:
1. HTTP (Hyper Text Transfer Protocol) helps us browse web pages using internet browsers.
2. Internet browser: Chrome
Teacher's Note:
a) Firefox, Edge, Safari or Opera are also correct browser names.
b) 1 mark is for the protocol and 1 mark for the browser name.
OR
B. Define tree topology. Also, write down any one limitation of tree topology. [2 Marks]
Answer:
1. Tree topology is a network topology that combines the features of bus and star topologies. Groups of star-configured computers are connected to a central bus backbone.
2. Limitation: Failure of the main backbone cable can bring down the entire network.
Teacher's Note:
a) Another accepted limitation: it is expensive because it needs a lot of cable and network devices.
b) 1 mark is for the definition and 1 mark for one limitation.
Section-C ( 3 x 3 = 9 Marks)
29. A. Write and call a Python function to read "History.txt" and display all lines that contain a four-digit year (e.g., 1999, 2024 etc.) [3 Marks]
Answer:
def DisplayYearLines( ):
f = open("History.txt", "r")
for line in f:
words = line.split()
for w in words:
if w.isdigit() and len(w) == 4:
print(line)
break
f.close()
DisplayYearLines( )
Teacher's Note:
a) Marks: half a mark for the function header, half a mark for opening the file, one and a half marks for the logic and half a mark for calling the function.
b) break stops checking the rest of the words, so a line with two years is printed only once.
c) Do not forget to call the function, as the question asks you to "write and call" it.
OR
B. Write a Python function that displays the number of times the word "Python" appears in a text file named "Prog.txt". [3 Marks]
Answer:
def count_python():
count = 0
with open("Prog.txt", 'r') as file:
text = file.read()
words = text.split()
for word in words:
if word.lower() == "python":
count += 1
print("The word Python appears", count, "times.")
Teacher's Note:
a) Half a mark each for: function header, opening the file, reading it, splitting into words, using the counter and displaying the result.
b) word.lower() makes the check case-insensitive, so "python" and "PYTHON" are also counted.
c) The with statement closes the file automatically.
30. A list containing records of books is given as:
B = [("Machine Learning Basics", 550), ("World Geography", 450), ("Wonder World", 140), ("AI Revolution", 750)]
Write the following user-defined functions to perform operations on a stack named Books:
I. Push_element(): Push only those books whose price is more than 250 into the stack.
II. Pop_element(): Pop the items from the stack and display them.
After all items are popped, display "Stack Empty".
Expected Output:
('AI Revolution', 750)
('World Geography', 450)
('Machine Learning Basics', 550)
Stack Empty [3 Marks]
Answer:
I.
B = [("Machine Learning Basics", 550),("World Geography", 450),("Wonder World", 140),("AI Revolution", 750)]
Books = [ ]
def Push_element():
for item in B:
if item[1] > 250:
Books.append(item)
II.
def Pop_element():
while Books:
print(Books.pop())
print("Stack Empty")
Teacher's Note:
a) item[1] is the price; "Wonder World" (140) is not pushed.
b) pop() removes the last item pushed first (LIFO), which is why "AI Revolution" is displayed first.
c) Each part carries one and a half marks.
31. A. Write a Python function avg_len( ) segment that adds up the lengths of all the words in a list and then prints the average (mean) length. [3 Marks]
Answer:
def avg_len(words):
total = 0
count = 0
for w in words:
total += len(w)
count += 1
return total / count
my_words = ["computer", "science", "python", "data"]
print("Average word length:", avg_len(my_words))
Teacher's Note:
a) Marks: half a mark for the function definition, 2 marks for the logic and half a mark for the print/return statement.
b) For the sample list, total = 8 + 7 + 6 + 4 = 25 and the average is 25 / 4 = 6.25.
c) len(words) can also be used in place of the count variable.
OR
B. Consider the tuple pairs = ((2,5),(4,2),(9,8),(12,10)). Write a Python function cnt_even( ) to count the number of pairs (a, b) where both a and b are even. [3 Marks]
Answer:
pairs = ((2,5), (4,2), (9,8), (12,10))
def cnt_even(t):
c = 0
for a, b in t:
if a % 2 == 0 and b % 2 == 0:
c += 1
return c
print("Number of even-even pairs:", cnt_even(pairs))
Teacher's Note:
a) Marks: half a mark for the function definition, 2 marks for the logic and half a mark for the print/return statement.
b) Only (4,2) and (12,10) have both numbers even, so the function returns 2.
c) Use and, not or, because both a and b must be even.
Section-D ( 4 x 4 = 16 Marks)
32. Consider the table TECH_EVENT_REG as given below:
reg_id | participant_name | event_name | grade | reg_fee
501 | Aarav | Hackathon | 11 | 200
502 | Riya | RoboRace | 10 | 150
503 | Krish | WebDev Challenge | 12 | 250
504 | Navya | Hackathon | 11 | 200
505 | Samaira | CodeSprint | 9 | 100
506 | Rohan | RoboRace | 10 | 150
A. Write the following queries:
I. To display the number of participants in each event where the number of participants is greater than 1.
II. To display the distinct event names available in the Tech Event.
III. To display details of participants whose names contain the letters 'an'.
IV. To display all records of TECH_EVENT_REG sorted by participant_name in descending order. [4 Marks]
Answer:
I. select event_name, count(*) as total_participants from tech_event_reg group by event_name having count(*) > 1;
II. select distinct event_name from tech_event_reg;
III. select * from tech_event_reg where participant_name like '%an%';
IV. select * from tech_event_reg order by participant_name desc;
Teacher's Note:
a) A condition on count(*) must be written in HAVING, not in WHERE.
b) In LIKE, % stands for any number of characters, so '%an%' finds 'an' anywhere in the name.
c) Each query carries 1 mark.
OR
B. Predict the output of the following:
I. Select participant_name, event_name from tech_event_reg where grade = 11;
II. Select event_name, count(*) from tech_event_reg group by event_name;
III. Select participant_name from tech_event_reg where event_name like '%challenge';
IV. Select max(reg_fee) from tech_event_reg where grade in (9, 10); [4 Marks]
Answer:
I.
participant_name | event_name
Aarav | Hackathon
Navya | Hackathon
II.
event_name | COUNT(*)
Hackathon | 2
RoboRace | 2
WebDev Challenge | 1
CodeSprint | 1
III.
participant_name
Krish
IV.
MAX(reg_fee)
150
Teacher's Note:
a) LIKE in MySQL is not case-sensitive, so '%challenge' matches "WebDev Challenge".
b) Grades 9 and 10 have fees 150, 100 and 150, so the maximum is 150.
c) Write the column headings along with the rows; each output carries 1 mark.
33. Kabir runs a vehicle rental agency and maintains a CSV file named Rentals.csv.
The file stores daily rental details with columns:
Vehicle_ID, Vehicle_Type, Hours_Rented, Rate_Per_Hour
Create the following user-defined functions:
I. AddRental() - to accept rental details from the user and append them to Rentals.csv.
II. CalculateTotalRent() - to calculate and return the total rent earned (Hours_Rented × Rate_Per_Hour). [4 Marks]
Answer:
import csv
def AddRental():
Vehicle_ID = input("Enter Vehicle ID: ")
Vehicle_Type = input("Enter Vehicle Type: ")
Hours_Rented = input("Enter Hours Rented: ")
Rate_Per_Hour = input("Enter Rate Per Hour: ")
with open("Rentals.csv", "a") as f:
w = csv.writer(f)
w.writerow([Vehicle_ID, Vehicle_Type, Hours_Rented, Rate_Per_Hour])
print("Rental record added successfully.")
def CalculateTotalRent():
total = 0
f = open("Rentals.csv", "r")
r = csv.reader(f)
for row in r:
hours = int(row[2])
rate = int(row[3])
total += hours * rate
print("Total Rent Earned:", total)
f.close()
Teacher's Note:
a) AddRental(): half a mark each for taking input, opening in append ("a") mode, creating the writer object and using writerow().
b) CalculateTotalRent(): half a mark each for opening in read mode, creating the reader object, converting to int and calculating, and displaying the total.
c) csv.reader gives every value as a string, so int() is needed before multiplying; since the question says "return", you may also add return total at the end.
34. Aditi is managing an events database and needs to access certain information from the chess_event and registrations tables for an upcoming survey. Help her extract the required information by writing the appropriate MySQL queries as per the tasks mentioned below:
Table: Chess_Event
Event_ID | Event_Name | Event_Date | Venue | Max_Participants
101 | Inter-School Chess Championship | 2025-01-15 | Auditorium Hall | 60
102 | Rapid Chess Tournament | 2025-02-10 | Activity Room 3 | 40
103 | Under-16 Chess Cup | 2025-03-05 | Sports Complex Room 2 | 50
104 | Teachers vs Students Chess Meet | 2025-04-12 | Library Conference Area | 30
105 | Open Blitz Chess Challenge | 2025-05-20 | IT Lab 1 | 80
Table: Registrations
Reg_ID | Student_Name | Class | Event_ID | Registration_Date
1 | Aarav Singh | 9A | 101 | 2024-12-20
2 | Navya Sharma | 9C | 103 | 2025-01-12
3 | Rudransh Verma | 10B | 102 | 2025-01-25
4 | Daksh Lal | 9B | 104 | 2025-02-18
5 | Abhijay Malhotra | 11A | 105 | 2025-03-30
6 | Krish Sharma | 10A | 101 | 2024-12-22
7 | Manas Taneja | 8C | 102 | 2025-01-28
8 | Riya Kapoor | 11B | 105 | 2025-04-01
9 | Harsh Mehta | 12A | 103 | 2025-02-20
10 | Simran Kaur | 9D | 104 | 2025-03-05
I. Write a MySQL query to update the venue of the event "Inter-School Chess Championship" to "Multi-Purpose Hall".
II. Display the details of all chess events scheduled after 2025-01-01.
III. Write a MySQL query to display the registration details of students who have registered for events scheduled in 'Auditorium Hall', 'Activity Room 3', or 'Library Conference Area'.
IV. a. Display the student_name along with the event_name for all registrations
or
b. Write a MySQL query to display the cartesian product of Chess_Event and Registrations tables. [4 Marks]
Answer:
I. UPDATE Chess_Event SET Venue = 'Multi-Purpose Hall' WHERE Event_Name = 'Inter-School Chess Championship';
II. SELECT * FROM Chess_Event WHERE Event_Date > '2025-01-01';
III. SELECT * FROM Registrations R JOIN Chess_Event C ON R.Event_ID = C.Event_ID WHERE C.Venue IN ('Auditorium Hall', 'Activity Room 3', 'Library Conference Area');
IV. a. SELECT R.Student_Name, C.Event_Name FROM Registrations R JOIN Chess_Event C ON R.Event_ID = C.Event_ID;
OR
b. SELECT * FROM Chess_Event, Registrations;
Teacher's Note:
a) The marking scheme writes the table name as CHESS_EVENTS; use the name given in the question, Chess_Event.
b) Event_ID is the common column that joins the two tables; dates are written in quotes in 'YYYY-MM-DD' form.
c) The cartesian product has 5 × 10 = 50 rows; each query carries 1 mark.
35. MySQL database named LibraryDB has a table book_records which contains the following attributes:
• Book_ID: ID of the book (Integer)
• Book_Title: Title of the book (String)
• Author: Author of the book (String)
• Copies: Number of copies available (Integer)
Consider the following details to establish Python-MySQL connectivity:
• Username: librarian
• Password: lib@2025
• Host: localhost
Write a Python-MySQL program to change the Book_Title to 'Data Structures in Python' for the record whose Book_ID is 109 in the book_records table. [4 Marks]
Answer:
import mysql.connector
con=mysql.connector.connect(host="localhost",user="librarian",password="lib@2025",database="LibraryDB")
cur = con.cursor()
q = "UPDATE book_records SET Book_Title='Data Structures in Python' WHERE Book_ID=109"
cur.execute(q)
con.commit()
print("Book title updated successfully.")
cur.close()
con.close()
Teacher's Note:
a) Marks: half a mark each for import, connection object and cursor object; 1 mark for the UPDATE query; 1 mark for execute() with commit(); half a mark for closing the connection.
b) Without con.commit(), the change is not saved in the database.
c) Use double quotes for the query string, because the title inside it uses single quotes.
Section-E (2 X 5 = 10 Marks)
36. A college administrator, Atul, maintains student course enrollment records.
Each record includes Roll_No, Student_Name, Course, Fees.
Write Python functions to: [5 Marks]
I. Input enrollment details and append them to a binary file. [2 Marks]
Answer:
def AddEnrollment():
Roll = int(input("Enter Roll No: "))
Name = input("Enter Student Name: ")
Course = input("Enter Course: ")
Fees = int(input("Enter Fees: "))
rec = [Roll, Name, Course, Fees] # LIST record
with open("Enrollments.dat", "ab") as f:
pickle.dump(rec, f)
print("Record added successfully.")
Teacher's Note:
a) Half a mark each for the function header, opening the file in "ab" mode, taking input and using pickle.dump().
b) "ab" adds new records at the end without erasing the old ones; "wb" would erase them.
c) The statement import pickle is needed in the program; the scheme ignores it in the marking.
II. Update the Fees of all students enrolled in the "Data Science" course to 75000. [3 Marks]
Answer:
import pickle
def UpdateFees():
updated = False
records = []
with open("Enrollments.dat", "rb") as file:
try:
while True:
rec = pickle.load(file)
if rec[2] == "Data Science": # Course at index 2
rec[3] = 75000 # Fees at index 3
updated = True
records.append(rec)
except EOFError:
pass
with open("Enrollments.dat", "wb") as file:
for rec in records:
pickle.dump(rec, file)
if updated:
print("Fees updated for Data Science students.")
else:
print("No student enrolled in Data Science found.")
Teacher's Note:
a) Marks: half a mark for the header, half a mark for opening the file, 1 mark for load() with a while loop and try-except, and 1 mark for checking the condition and updating.
b) pickle.load() raises EOFError at the end of the file, which is how the loop stops.
c) All records are read into a list first and then written back in "wb" mode, so the changed fees are saved.
37. AKA University is setting up its Academic blocks at Raipur and planning to set up a network. The university has 3 academic blocks and one Human Resource Center as shown in the diagram below:
Center to center distances between various blocks is as follows:
Law Block to Business Block | 90 m
Law Block to Technology Block | 55 m
Law Block to HR Center | 120 m
Business Block to Technology Block | 70 m
Business Block to HR Center | 105 m
Technology Block to HR Center | 45 m
Number of Computers in each of the Blocks/Center is as follows:
Law Block | 30
Technology Block | 55
HR Center | 120
Business Block | 45 [5 Marks]
[Figure: Layout of four buildings - Business Block and Technology Block in the top row, Law Block at the bottom left and HR Center at the bottom right.]
I. Suggest the most suitable place (i.e. Block/Center) to install the server of this university with a suitable reason. [1 Mark]
Answer: HR Center, as it has the maximum number of computers (120).
Teacher's Note:
a) The server is placed where the most computers are, so that most of the traffic stays local.
b) Always write the reason; the name of the place alone is not enough.
II. Identify and draw the most suitable topology for connecting all the blocks if the university wants a centralized network management system. [1 Mark]
Answer: Star Topology.
Diagram: The HR Center (with the server) is at the centre, and separate cables go from the HR Center to the Business Block, the Technology Block and the Law Block.
Teacher's Note:
a) In a star topology every block is connected directly to the central node, which gives centralized management.
b) In the drawing, keep the server block (HR Center) at the centre of the star.
III. Suggest and placement of the following devices with reasons.
a. Repeater
b. Switch [1 Mark]
Answer:
a. Repeater: It should be placed between the HR Center and the Law Block, and between the HR Center and the Business Block, as the distance between them is more than 100 meters.
b. Switch: It should be placed in every block, as a network is to be formed in each and every block.
Teacher's Note:
a) HR Center to Law Block is 120 m and HR Center to Business Block is 105 m, both more than 100 m.
b) A repeater boosts a weak signal; a switch connects the computers inside a block.
IV. The Institute is planning to link its study center situated in Delhi. Suggest a way to connect it with reasonably high speed guided medium. [1 Mark]
Answer: Optical Fibre
Teacher's Note:
a) Optical fibre is a guided (wired) medium that gives very high speed over long distances.
b) Do not write satellite or radio waves, as the question asks for a guided medium.
V. A. The Vice-Chancellor wants to hold a face-to-face digital meeting with the Heads of Departments in all blocks simultaneously. Which Protocol will be used? [1 Mark]
Answer: VOIP (Voice Over Internet Protocol)
Teacher's Note:
a) VoIP carries voice (and video) calls over the Internet, which makes online meetings possible.
b) Write the full form along with the short form.
OR
B. What is the use of VoIP? [1 Mark]
Answer: Voice over Internet Protocol (VoIP) is a technology that allows users to make phone calls and other communications over the Internet instead of a traditional phone line.
Teacher's Note:
a) Keywords: "phone calls over the Internet" and "instead of a traditional phone line".
b) Write the full form of VoIP correctly.
Free study material for Computer Science
Download CBSE Sample Papers: Class 12 Computer Science
Class 12 Computer Science CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download PDF Download Guide
Access structured sample papers for Class 12 Computer Science. Solving the CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download provided above helps students understand official exam blueprints and tackle anticipated question formats with confidence.
Key Advantages of Solving CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download
- Curriculum Insights: Clarify chapter-wise weightage rules and question trends across Class 12.
- Gap Analysis: Check performance drops across sets to isolate specific Class 12 Computer Science topics needing extra attention.
- Time Efficiency: Working through objective and descriptive problems builds critical pacing to finish exams comfortably.
Post-Practice Strategy for Class 12 Computer Science
- Verify Answers: Compare your responses against professional teacher solutions provided in the sample paper keys.
- Error Analysis: Class 12 learners must review incorrect answers carefully to understand underlying mistakes.
- Concept Reinforcement: Consult the official NCERT book for Class 12 Computer Science when stuck before re-attempting problems.
FAQs
You can download the complete PDF for CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download for free from StudiesToday.com. Our resources for Class 12 Computer Science are updated for the latest academic session and follow the official exam pattern.
Yes, CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download comes with detailed, teacher-verified solutions. We have provided step-by-step answers for Computer Science to help students of Class 12 understand correct methodology and marking scheme.
Practicing this Computer Science paper helps in time management and identifying important topics. For Class 12, solving mock papers is the best way to gain confidence and reduce exam-day anxiety.
Yes, all our study materials for Class 12 Computer Science are provided in a mobile-friendly PDF format. You can easily download CBSE Class 12 Computer Science Sample Paper 2026 27 with Solutions PDF Download on your mobile device.