Competishun Header
Study Material

CBSE Computer Science Sample Paper Class 12 2026-27 with Solutions PDF: Python, SQL & Networks

By Rohit Gupta Oct 07, 2026 30 min read
CBSE Computer Science Sample Paper Class 12 with Solutions
Official CBSE Sample Paper 2026-27 · Solved by Competishun

CBSE Computer Science Sample Paper Class 12 2026-27 with Solutions PDF: Python, SQL & Networks

All 37 questions solved with answers, explanations and the marking scheme for the CBSE Class 12 Computer Science (083) sample paper 2026-27.

37Questions Solved
70Theory Marks
3 HrsDuration
083Subject Code
FreePDF Download

This page has the complete CBSE Computer Science sample paper class 12 2026-27 with solutions. All 37 questions of the official Computer Science (083) paper are solved below, from Python output questions to SQL queries and networking, with the marking scheme.

Computer Science answers are judged on exact code and exact output. A missing colon, a wrong indent or a misread loop range costs marks, so every code answer below is written in full and every output question explains how the result is reached.

Download the free PDF for offline practice, or open each question below.

Quick answer: The cbse computer science sample paper class 12 2026-27 solutions are available on this page as a free PDF, and every question is solved below with the marking scheme. The question paper itself is on our CBSE Class 12 sample paper 2026-27 page.
Free Download

Download Cbse computer science sample paper class 12 Solutions PDF

cbse computer science sample paper class 12 2026-27 solutions PDF first page

CBSE Class 12 Computer Science Sample Paper 2026-27: Complete Solutions

  • All 37 questions solved, including internal choices
  • Step-wise marking scheme for every answer
  • Clear explanations in simple language
  • Free, no login, works on mobile
Download Solutions PDF Question Paper
Paper Pattern

Computer Science Sample Paper Class 12 2026-27 Pattern

CBSE has stated that there is no change in the question paper design for the 2026-27 session, so this is the structure of your board paper.

SectionQuestionsQuestion TypesMarks
A1 to 21MCQ and output (1 mark each)21
B22 to 28Short answer (2 marks each)14
C29 to 313 marks each9
D32 to 354 marks each16
E36 to 375 marks each10
Total37Duration: 3 hours70

Official source: CBSE Academic, Sample Question Papers Class XII 2026-27.

How These Computer Science Sample Paper Solutions Are Written

Each question below opens into a full solution with three parts.

Answer

The correct option or the complete written answer, as you should write it in the exam.

Explanation

Why the answer is correct, so you can solve similar questions.

Marking Scheme

Where each mark is given, so you know what the examiner looks for.

Best way to use this page: attempt the full paper first in 3 hours, then open each question and compare. Questions that use a diagram, graph or table show the figure in the PDF.

Computer Science Sample Paper Solutions: Section A (Q1 to Q21, 1 mark each)

Q11 MarkWrite the output on execution of the following Python code:Tap to view answer and marking scheme
L1 = [10, 20, 25, 30]
L1.insert(1, 15)
print(L1)

Answer

[10, 15, 20, 25, 30]

Explanation

insert(1, 15) places 15 at index 1 and shifts every later element one position to the right.

Marking Scheme

1 mark for the correct answer.

Q21 MarkWhat will be the output of the following expression?Tap to view answer and marking scheme
Msg = "programming is amazing"
print(Msg.split("m"))

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']

Explanation

The string contains three m characters. Splitting on m gives four pieces; the two consecutive ms in “programming” produce an empty string between them. split() always returns a list, so option (c) is ruled out.

Marking Scheme

1 mark for the correct answer.

Q31 MarkWhich of the following data types in Python is mutable?Tap to view answer and marking scheme

a) Tuple b) String

c) Integer d) List

Answer

d) List

Explanation

A list can be changed in place after creation; tuples, strings and integers are immutable.

Marking Scheme

1 mark for the correct answer.

Q41 MarkA column in one table matching a primary key of another table is called a:Tap to view answer and marking scheme

a) Composite key b) Candidate key

c) Foreign key d) Super key

Answer

c) Foreign key

Explanation

A foreign key is an attribute in one relation that refers to the primary key of another relation and enforces referential integrity.

Marking Scheme

1 mark for the correct answer.

Q51 MarkConsider the following Python code. What will happen when this code is executed?Tap to view answer and marking scheme
t = (1, 2, 3)
l = [4, 5]
print(t + l)

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

Explanation

The + operator concatenates only sequences of the same type. tuple + list raises TypeError: can only concatenate tuple (not "list") to tuple.

Marking Scheme

1 mark for the correct answer.

Q61 MarkWhat possible output is expected to be displayed on the screen at the time of execution of the Python program from the following code?Tap to view answer and marking scheme
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="@@")

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@@

Explanation

random.randint(1, 2) returns 1 or 2 (both ends included); random.randrange(3, 4) can return only 3. So the loop runs over range(start_key, 4) - keys 1, 2, 3 when start_key is 1, giving Scrabble, Sudoku, Tic-Tac-Toe. Option (b) is the only reachable output.

Marking Scheme

1 mark for the correct answer.

Q71 MarkPredict the output for the following:Tap to view answer and marking scheme
Dl = {"Pen": 12, "Pencil": 6, "Scale": 5, "InkPen": 20}
print(12 in Dl)

a) False b) Error

c) None d) True

Answer

a) False

Explanation

The in operator on a dictionary searches the keys, not the values. The keys here are strings, so the integer 12 is not found.

Marking Scheme

1 mark for the correct answer.

Q81 MarkLong-distance communication without line-of-sight is mainly achieved using:Tap to view answer and marking scheme

a) Microwaves b) Ultraviolet

c) Radio waves d) X-rays

Answer

c) Radio waves

Explanation

Radio waves are omnidirectional and can be reflected by the ionosphere and bend around obstacles, so they travel long distances without a clear line of sight. Microwaves need line-of-sight transmission.

Marking Scheme

1 mark for the correct answer.

Q91 MarkWhich MySQL query will display all employees whose salaries are between 90,000 and 100,000 (including limits)?Tap to view answer and marking scheme
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;

Explanation

BETWEEN … AND … is inclusive of both limits. Option (a) excludes the limits; options (b) and

(d) match only the two exact values.

Marking Scheme

1 mark for the correct answer.

Q101 MarkWhat will be the output of the following Python statement:Tap to view answer and marking scheme
print(25 + 100 ** 1 ** 3 / 5)

Answer

45.0

Explanation

** is right-associative, so 1**3 is evaluated first and gives 1; then 100**1 is 100; 100/5 is 20.0; finally 25 + 20.0 is 45.0. Division always returns a float.

Marking Scheme

1 mark for the correct answer.

Q111 MarkWhat is the data type of the result when the expression 5 // 2 is evaluated in Python?Tap to view answer and marking scheme

a) float b) int

c) string d) None

Answer

b) int

Explanation

// is floor division. With both operands of type int the result is int - here 2.

Marking Scheme

1 mark for the correct answer.

Q121 MarkEvery network interface card (NIC) comes with its own ____ address.Tap to view answer and marking scheme

a) Internet Protocol (IP) b) Open Systems Interconnection (OSI)

c) Physical (MAC) d) Dynamic Host Configuration Protocol (DHCP)

Answer

c) Physical (MAC)

Explanation

The MAC (physical) address is burnt into the NIC by the manufacturer and is globally unique; an IP address, by contrast, is assigned by the network.

Marking Scheme

1 mark for the correct answer.

Q131 MarkIn a student table, “Class” can only take values from {IX, X, XI, XII}. This set is called the ____.Tap to view answer and marking scheme

a) Domain b) Tuple

c) Attribute d) Key

Answer

a) Domain

Explanation

The domain of an attribute is the set of all permissible values that the attribute may take.

Marking Scheme

1 mark for the correct answer.

Q141 MarkWhat would be written in the file errorlog.txt after the following code is run?Tap to view answer and marking scheme
def data(num):
    try:
        return 190 / (29 - num)
    except ZeroDivisionError:
        logfile = open("errorlog.txt", "w")
        logfile.write("Num was 29")
        logfile.close()
data(29)

Answer

Num was 29

Explanation

data(29) makes the denominator 29 − 29 = 0, which raises ZeroDivisionError. The handler opens the file in "w" mode and writes the text Num was 29.

Marking Scheme

1 mark for the correct answer.

Q151 MarkWhich of the following will NOT change if you insert a new record into a table?Tap to view answer and marking scheme

a) Cardinality b) Degree

c) Number of tuples d) Total rows

Answer

b) Degree

Explanation

Degree is the number of attributes (columns) in a relation and is unaffected by inserting a row. Cardinality, number of tuples and total rows all mean the row count, which increases by one.

Marking Scheme

1 mark for the correct answer.

Q161 MarkWhat will be the output of the following Python code?Tap to view answer and marking scheme
y = 8
def update():
    y = y + 2
    print(y)
update()

a) 10 b) 8

c) Error d) None

Answer

c) Error

Explanation

Assigning to y inside update() makes y a local name for the whole function, so reading it in y = y + 2 before assignment raises UnboundLocalError. Declaring global y would fix it.

Marking Scheme

1 mark for the correct answer.

Q171 MarkIn ____ switching, before a communication starts, a dedicated path is identified between the sender and the receiver.Tap to view answer and marking scheme

a) Graph b) Plot

c) Circuit d) Packet

Answer

c) Circuit

Explanation

In circuit switching a physical path is reserved for the entire duration of the communication, as in a traditional telephone call.

Marking Scheme

1 mark for the correct answer.

Q181 MarkWhat will be the output of the following Python code?Tap to view answer and marking scheme
text = "Drone Expo"
print(text[-2::-4])

Answer

peD

Explanation

In "Drone Expo", index −2 is p (index 8). A step of −4 then moves to index 4 (e) and index 0

(D), giving peD.

Marking Scheme

1 mark for the correct answer.

Q191 MarkWhich MySQL command correctly removes an attribute Age from table Student?Tap to view answer and marking scheme

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;

Explanation

Removing a column changes the *structure* of the table, so the DDL command ALTER TABLE … DROP COLUMN is used. DELETE removes rows, not columns.

Marking Scheme

1 mark for the correct answer. Questions 20 and 21 - Assertion (A) and Reason (R)

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.

Q201 MarkAssertion (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.Tap to view answer and marking scheme

Answer

c) A is True but R is False.

Explanation

A is true - rb opens an existing binary file for reading only, so its contents cannot be altered. R is false - in any read mode (r, rb) a missing file raises FileNotFoundError; it is the write and append modes (w, wb, a, ab) that create a new file.

Marking Scheme

1 mark for the correct answer.

Q211 MarkTap to view answer and marking scheme
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.

Answer

c) A is True but R is False.

Explanation

A is true - IS NULL is the correct way to find rows where a value has not been entered. R is false - NULL means “unknown”, so a comparison such as Guardian_Phone = NULL evaluates to NULL (never TRUE) and returns no rows. Only IS NULL / IS NOT NULL work.

Marking Scheme

1 mark for the correct answer. Questions 22 to 28 · 2 marks each · 14 marks

Computer Science Sample Paper Solutions: Section B (Q22 to Q28, 2 marks each)

Q222 MarksA. Define global variable and local variable with a suitable example.Tap to view answer and marking scheme

OR

B. Write the difference between the seek() and tell() methods in Python text file handling with a suitable example.

Answer and Solution

A Global variable - declared outside every function; it is accessible from anywhere in the program.

x = 10 # global variable
print(x)

Local variable - declared inside a function; it exists only while that function runs and is accessible only inside it.

def demo():
y = 5 # local variable
    print(y)

Answer and Solution

B tell() returns the current position (in bytes) of the file pointer, whereas seek(offset) moves the file pointer to the given position.

f = open("file.txt", "r")
print(f.tell()) # e.g. 0 - pointer at the beginning
f.seek(5) # moves the pointer to the 5th byte
print(f.tell()) # 5

Marking Scheme

1 mark for the correct difference / definitions + ½ mark for each correct example = 2 marks.

Q232 MarksThe 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.Tap to view answer and marking scheme
words=["Class Test","Term Exams","Pre-board Exam","Board Exam’]
L=len(words)
for i in range(L, -1, -1)

Print (words[i] , end = " ")

Answer and Solution

corrected program (corrections underlined)

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 = " ") Errors corrected

• The closing quote of "Board Exam’ was a typographic quote - replaced by a straight double quote.

• A colon was missing at the end of the for statement header.

• Print must be written in lower case as print - Python is case-sensitive.

• range(L, -1, -1) starts at index L, which is out of range - it must start at L-1.

Marking Scheme

½ mark for each of the 4 corrections = 2 marks.

Q242 MarksA. Write a Python function capitalize_words(words) that takes a list of strings words and returns a new list with each word capitalized. Example: if the input is ["python", "computer", "science"], the output should be ["Python", "Computer", "Science"].Tap to view answer and marking scheme

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.

Answer and Solution

A

def capitalize_words(words): # words is a list of strings
    result = []
    for w in words:
        result.append(w.capitalize())
    return result
print(capitalize_words(["python", "computer", "science"]))

Answer and Solution

B

def sum_positive(list1): # list1 is a list of numbers
total = 0
for num in list1:
    if num > 0:

total += num

    print(total)
sum_positive([10, -5, 20, -3, 7])

Marking Scheme

½ mark for the function definition + 1 mark for the correct / similar logic + ½ mark for the correct return or print statement = 2 marks.

Q252 MarksTap to view answer and marking scheme
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.

OR

B. Predict the output of the following Python code:
    text = "Python Programming"
    print(text.replace("o", "0"))
    print(text.find("z"))

Answer and Solution

A

I. username.startswith("admin")

II. data.count(max(data)) # max(data) is 9, which occurs 2 times

Answer and Solution

B Pyth0n Pr0gramming -1 replace() substitutes every occurrence of "o"; find() returns -1 when the substring is absent (it does not raise an error, unlike index()).

Marking Scheme

1 mark for each correct statement / output line = 2 marks.

Q262 MarksPredict the output of the following Python code:Tap to view answer and marking scheme
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)

Answer

['#', 'l', '#', 'd', 10]

Solution

character by character Index Character Test satisfied Appended 0 g none (lower-case letter) '#' 1 L isupper() 'l' 2 a none (lower-case letter) '#' 3 D isupper() 'd' 4 5 isdigit() 10 (int('5') * 2)

Marking Scheme

2 marks for the fully correct output.

Q272 MarksA. Write suitable commands to do the following in MySQL.Tap to view answer and marking scheme

I. Display a list of all the relations stored in a database.

II. Delete a database named CS_SP.

OR

B. Differentiate between the ALTER and UPDATE commands in MySQL with a suitable example.

Answer and Solution

A

I. SHOW TABLES;

II. DROP DATABASE CS_SP;

Answer and Solution

B

ALTER UPDATE

A DDL (Data Definition Language) command. A DML (Data Manipulation Language) command. Changes the structure (schema) of a table - adds, modifies, renames or drops a column or a constraint. Changes the data stored in the existing rows of a table - modifies values in one or more columns. Example: ALTER TABLE Student ADD Age INT; Example: UPDATE Student SET Age = 17 WHERE RollNo = 5;

Marking Scheme

A - 1 mark for each correct command. B - 1 mark for the correct difference + ½ mark for each correct example = 2 marks.

Q282 MarksA. Which protocol helps us to browse through web pages using internet browsers? Name any one internet browser.Tap to view answer and marking scheme

OR

B. Define tree topology. Also, write down any one limitation of tree topology.

Answer and Solution

A

• HTTP (HyperText Transfer Protocol) is the protocol used to browse web pages through internet browsers. (Its secure version is HTTPS.)

• Any one browser: Google Chrome / Mozilla Firefox / Microsoft Edge / Safari / Opera.

Answer and Solution

B

• Tree topology combines the characteristics of bus and star topologies: groups of star-configured computers are connected to a central bus backbone.

• Limitation (any one) - failure of the main backbone cable brings down the entire network; it is expensive because it needs a large amount of cable and many network devices; it is difficult to configure and maintain as the network grows.

Marking Scheme

A - 1 mark for the correct protocol + 1 mark for any one browser name. B - 1 mark for the correct definition + 1 mark for any one limitation = 2 marks. Questions 29 to 31 · 3 marks each · 9 marks

Computer Science Sample Paper Solutions: Section C (Q29 to Q31, 3 marks each)

Q293 MarksA. 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.).Tap to view answer and marking scheme

OR

B. Write a Python function that displays the number of times the word "Python" appears in a text file named "Prog.txt".

Answer and Solution

A

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()

Marking Scheme

½ mark for the correct function header + ½ mark for correctly opening the file + 1½ marks

for the correct / similar logic for displaying the desired lines + ½ mark for correctly calling the function = 3

marks.

Answer and Solution

B

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.")
count_python()

Marking Scheme

½ mark each for - the function header, opening the file, reading from the file, splitting the text into words, correct use of the counter variable, and displaying the result = 3 marks.

Q303 MarksA list containing records of books is given as:Tap to view answer and marking scheme
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

Answer and Solution

B = [("Machine Learning Basics", 550), ("World Geography", 450),
    ("Wonder World", 140), ("AI Revolution", 750)]
Books = []
# I.
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")
Push_element()
Pop_element()

Only three books cost more than 250, so the stack holds them in insertion order; pop() removes from the top (the end of the list), which produces the expected LIFO output.

Marking Scheme

1½ marks for each correct function = 3 marks.

Q313 MarksA. Write a Python function avg_len() that adds up the lengths of all the words in a list and then prints the average (mean) length.Tap to view answer and marking scheme

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.

Answer and Solution

A

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)) # 6.25

Answer and Solution

B

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)) # 2

Only (4, 2) and (12, 10) have both members even, so the count is 2.

Marking Scheme

½ mark for the function definition + 2 marks for the correct / similar logic + ½ mark for the print / return statement = 3 marks. Questions 32 to 35 · 4 marks each · 16 marks

Computer Science Sample Paper Solutions: Section D (Q32 to Q35, 4 marks each)

Q324 MarksTap to view answer and marking scheme
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.

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);

Answer and Solution

A

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;

Answer and Solution

B I. participant_name event_name Aarav Hackathon Navya Hackathon II. event_name COUNT(*) Hackathon 2 RoboRace 2 WebDev Challenge 1 event_name COUNT(*) CodeSprint 1 III. participant_name Krish IV.

MAX(reg_fee)

150 For III, '%challenge' matches a value that *ends* with “challenge”; MySQL string comparison is case-insensitive by default, so WebDev Challenge qualifies. For IV, grades 9 and 10 give fees 100, 150 and 150, so the maximum is 150.

Marking Scheme

4 × 1 mark for each correct query (part A) or each correct output (part B) = 4 marks.

Q334 MarksKabir 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 theTap to view answer and marking scheme
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).

Answer and Solution

import csv
# I.
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.")
# II.
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

f.close()
print("Total Rent Earned:", total)
return total

Note: import csv may be treated as part of the complete program and need not be repeated in each part.

Marking Scheme

I - ½ mark each for correctly taking user input, opening the file in append mode, creating the writer object, and using writerow() = 2 marks. II - ½ mark each for opening the file in the right mode, creating the reader object, correct calculation after converting to integers, and correctly returning / displaying the total rent = 2 marks. Total 4 marks.

Q344 MarksAditi 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...Tap to view answer and marking scheme

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_Participa nts 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 the Chess_Event and Registrations tables.

Answer and Solution

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 R.* 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;

(b) SELECT * FROM Chess_Event, Registrations;

Marking Scheme

4 × 1 mark for each correct query = 4 marks. For IV, either alternative (a) or (b) is to be attempted.

Q354 MarksTap to view answer and marking scheme
A 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.

Answer and Solution

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()

commit() is essential - without it the UPDATE is not saved permanently in the database.

Marking Scheme

½ mark for correctly importing the connector + ½ mark for creating the connection object + ½ mark for creating the cursor object + 1 mark for the correct UPDATE query + 1 mark for executing the query with commit() + ½ mark for correctly closing the connection = 4 marks. Questions 36 and 37 · 5 marks each · 10 marks

Computer Science Sample Paper Solutions: Section E (Q36 and Q37, 5 marks each)

Q362 + 3 = 5 MarksA college administrator, Atul, maintains student course enrollment records. Each record includes Roll_No,Tap to view answer and marking scheme
Student_Name, Course, Fees. Write Python functions to:

I. Input enrollment details and append them to a binary file. [2]

II. Update the Fees of all students enrolled in the “Data Science” course to 75000. [3]

Answer and Solution

I

import pickle
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] # record as a list
    with open("Enrollments.dat", "ab") as f:
        pickle.dump(rec, f)
    print("Record added successfully.")

Marking Scheme

½ mark each for - correctly defining the function header, opening the file in append mode, taking user input, and using the dump() method of the pickle module = 2 marks.

Answer and Solution

II

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 is at index 2
rec[3] = 75000 # Fees is 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.")

Note: import pickle may be treated as part of the complete program and need not be repeated in each part.

Marking Scheme

½ mark for correctly defining the function header + ½ mark for correctly opening the file + 1 mark for using load() with a while loop and a try … except block + 1 mark for checking the condition and updating the value = 3 marks.

Q375 MarksAKA University is setting up its Academic blocks at Raipur and planning to set up a network. The universityTap to view answer and marking scheme
has 3 academic blocks and one Human Resource Centre as shown in the diagram below:

Centre-to-centre distances between various blocks:

[ Distance table of the question paper to be inserted here ]

Number of computers in each of the Blocks / Centre:
[ Computer-count table of the question paper to be inserted here ]

I. Suggest the most suitable place (i.e. Block / Centre) to install the server of this university with a suitable reason.

II. Identify and draw the most suitable topology for connecting all the blocks if the university wants a centralized network management system.

III. Suggest the placement of the following devices with reasons: (a) Repeater (b) Switch

IV. The Institute is planning to link its study centre situated in Delhi. Suggest a way to connect it with a reasonably high-speed 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? OR (b) What is the use of VoIP?

Answer and Solution

I. The HR Centre, as it has the maximum number of computers. Placing the server where the largest number of nodes is located keeps most of the traffic local and minimises network delay.

II. Star topology - every block is connected directly to the HR Centre, which acts as the central node. This gives the centralized management the university wants, and a fault in one link does not affect the others.

III. (a) Repeater - to be placed on the HR Centre → Law Block link and on the HR Centre → Business Block link, because the distance on these links is more than 100 metres and the signal would otherwise become weak.

(b) Switch - one switch is to be placed in each block / centre, since a separate local network has to be formed inside every block and a switch connects those computers and forwards data only to the intended node.

IV. Optical fibre cable - it is a guided medium that offers very high bandwidth, very low attenuation over long distances and immunity from electromagnetic interference, so it is the best choice for linking the Delhi study centre.

V. (a) VoIP (Voice over Internet Protocol).

(b) VoIP is a technology that allows users to make voice calls and hold audio / video conversations over the Internet instead of a traditional telephone line, converting the voice signal into data packets. It is used

for internet telephony, video conferencing and online meetings, and is far cheaper than conventional

long-distance calling.

Marking Scheme

5 × 1 mark for each correct part = 5 marks. For part V, either alternative (a) or (b) is to be attempted.

From the Marking Scheme

Where Students Lose Marks in Class 12 Computer Science

The marking scheme of the cbse computer science sample paper class 12 shows clear patterns in where marks slip away.

  • Trace output line by line. Write down variable values at each step.
  • Write complete Python code. Indentation and colons matter in function questions.
  • Know SQL clauses well. GROUP BY, HAVING, ORDER BY and joins appear every year.
  • Practise file handling. Text, binary and CSV file functions are regular long questions.
  • Learn network terms with examples. Topologies, devices and protocols are scoring.
Keep Practising

Practise More With Competishun

Solving one sample paper is a start. Regular timed tests and quick concept revision are what turn practice into marks.

Test Series

Competishun Test Series

Check where you stand with timed, exam-style tests and detailed reports.

  • Board and competitive exam practice
  • All-India comparison
  • Question-wise analysis
View Test Series
Free on the App

Competishun App

Video lectures, notes and practice in one place, from senior faculty with 18 to 25 years' experience.

  • Concept videos you can replay
  • Practice after every topic
  • Works on any Android phone
Get the App

FAQs on Cbse computer science sample paper class 12

You can download it free from this page. Tap Download Solutions PDF near the top to get all 37 solved questions with the marking scheme.
Yes. The questions are from the official CBSE Class 12 Computer Science (083) sample paper for 2026-27, and the solutions are prepared by Competishun.
The paper has 37 questions for 70 marks, and the time allowed is 3 hours.
Yes. Every answer in the PDF shows the marking scheme, so you can see where each mark is given.
No. CBSE has stated that there is no change in the question paper design and assessment pattern for the 2026-27 session.
The question papers for all subjects are on our CBSE Class 12 sample paper 2026-27 page, linked on this page.

Explore Our Courses

Our Test Series

More From Our Blog

Showing 12 of 313 blogs