CBSE Class 12 CS 083 Sample QP 2026-27 with Solution

CBSE Class 12 Computer Science (Code 083) Sample Question Paper 2026-27 with Solution is a useful practice resource for students preparing for the CBSE board examination. It follows the latest syllabus and helps students understand the CBSE Class 12 Computer Science exam pattern 2026-27, important question types, and marking scheme.

CBSE-Class-12-CS-083-Sample-Question-Paper-2026-27-with-Solution

This CBSE Class 12 Computer Science 083 sample paper 2026-27 with solutions covers important areas such as Python programming, SQL, Pandas, computer networks, and database concepts. Students can use the solved paper for Class 12 Computer Science board exam preparation, quick revision, and improving time management and answer-writing skills.

CBSE Class 12 CS 083 Sample QP 2026-27 with Solution

You can download the free PDF of this sample pre-board question paper from our website and start practicing today. Download Link available in last.

The Year-Wise CBSE Class 12 Computer Science (083) Pre-Board and Sample Question Papers with Solutions are provided at the bottom of this post.

CBSE Class 12 CS 083 Sample Question Paper Session (2026-27)

CBSE | DEPARTMENT OF SKILL EDUCATION
COMPUTER SCIENCE (SUBJECT CODE - 083)
Sample Question Paper (SQP) Solution for Class XII (Session 2026-2027)

Max. Time: 3 Hours
Max. Marks: 70

General Instructions:
  1. This question paper contains 37 questions.
  2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt only one of the choices in such questions.
  3. The paper is divided into 5 Sections- A, B, C, D and E.
  4. Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
  5. Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
  6. Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
  7. Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
  8. Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
  9. All programming questions are to be answered using Python Language only.
SECTION A

1. Write the output on execution of the following Python code:
L1=[10,20,25,30]
L1.insert(1,15)
print(L1)
Ans: [10, 15, 20, 25, 30]

2. What will be the output of the following expression?
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']

3. Which of the following data types in Python is mutable?
a) Tuple
b) String
c) Integer
d) List

4. A column in one table matching a primary key of another table is called a:
a) Composite key
b) Candidate key
c) Foreign key
d) Super key

5. Consider the following Python code:
t = (1, 2, 3)
l = [4, 5]
print(t + l)
What will happen when this code is executed?
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])

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="@@")
a) Sudoku@@Tic-Tac-Toe@@Puzzle@@
b) Scrabble@@Sudoku@@Tic-Tac-Toe@@
c) Chess@@Scrabble@@Tic-Tac-Toe@@
d) Scrabble@@Tic-Tac-Toe@@

7. Predict the output for the following:
Dl={"Pen":12, "Pencil":6, "Scale":5, "InkPen":20}
print(12 in Dl)
a) False
b) Error
c) None
d) True

8. Long-distance communication without line-of-sight is mainly achieved using:
a) Microwaves
b) Ultraviolet
c) Radio waves
d) X-rays

9. Which MySQL query will display all employees whose salaries are between 90,000
and 100,000 (including limits)?
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;

10. What will be the output of the following Python statement:
print(25+100**1**3/5)
Ans: 45.0

11. What is the data type of the result when the expression 5 // 2 is evaluated in Python?
a) float
b) int
c) string
d) None

12. Every network interface card (NIC) comes with its own ________ address.
a) Internet Protocol (IP)
b) Open Systems Interconnection (OSI)
c) Physical (MAC) Address
d) Dynamic Host Configuration Protocol (DHCP)

13. In a student table, “Class” can only take values from {IX, X, XI, XII}. This set is called
the ________.
a) Domain
b) Tuple
c) Attribute
d) Key

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)
Ans: Num was 29

15. Which of the following will NOT change if you insert a new record into a table?
a) Cardinality
b) Degree
c) Number of tuples
d) Total rows

16. What will be the output of the following Python code?
y = 8
def update():
y = y + 2
print(y)
update()
a) 10
b) 8
c) Error
d) None

17. In ______ switching, before a communication starts, a dedicated path is identified
between the sender and the receiver.
a) Graph
b) Plot
c) Circuit
d) Packet

18. What will be the output of the following Python code?
text = "Drone Expo"
print(text[-2: :-4])
Ans: peD

19. Which MySQL command correctly removes an attribute Age from table Student?
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;

Q.20 and Q.21 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

Q.20 Assertion (A): The expression (1, 2, 3, 4).append(5) in Python will modify the original sequence datatype.
Reason (R): In rb mode, if the file does not exist, Python creates a new empty file.
Ans: c) A is True but R is False

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.
Ans: c) A is True but R is False

SECTION B

22. Define global variable and local variable with a suitable example.
Ans: A global variable is defined outside a function and can be accessed from anywhere in the program.
x = 10  # Global variable
print(x)
A local variable is defined inside a function and can be accessed only within that function.
def demo():
    y = 5  # Local variable
    print(y)
demo()
OR
Write the difference between the seek() and tell() methods in Python text file handling with a suitable example.
Ans: tell() returns the current position of the file pointer in the file.
f = open("file.txt", "r")
print(f.tell())  # Usually 0 when the file is first opened
f.close()
seek(offset) moves the file pointer to the specified position.
f = open("file.txt", "r")
f.seek(5)  # Moves the file pointer to position 5
f.close()

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 = " ")
Ans:
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=" ")

24. 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"].
Ans:
def capitalize_words(words):  # words is a list of strings
    result = []
    for w in words:
        result.append(w.capitalize())
    print(result)
OR
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.
Ans:
def sum_positive(list1):  # list1 is a list of numbers
    total = 0
    for num in list1:
        if num > 0:
            total += num
    print(total)

25. A. (Answer using Python built-in methods/functions only):
i) Write a statement to check whether the string username starts with "admin".
Ans: username.startswith("admin")
ii) Given data = [2, 7, 9, 9, 2], write a statement to count how many times the largest element occurs.
Ans: data.count(max(data))
OR
B. Predict the output of the following Python code:
text = "Python Programming"
print(text.replace("o", "0"))
print(text.find("z"))
Ans:
Pyth0n Pr0gramming
-1

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)
Ans: ['#', 'l', '#', 'd', 10]

27. A. Write suitable commands to do the following in MySQL.
i) Display a list of all the relations stored in a database.
Ans: Show tables;
ii) Delete a database named CS_SP.
Ans: Drop database CS_SP;

OR

Differentiate between alter and update command in MySQL with a suitable example.
Ans:
ALTERUPDATE
Used to change the structure of a table. It adds, deletes or modifies columns or constraints.Used to modify the data stored in the table. It changes the values in rows.
Eg: ALTER TABLE Employee ADD age INT;Eg: UPDATE Employee SET salary = 50000 WHERE emp_id = 10;

28. Which protocol helps us to browse through web pages using internet browsers? Name any one internet browser.
Ans: HTTP (Hyper Text Transfer Protocol) helps us browse web pages using internet browsers.
Examples: Google Chrome, Mozilla Firefox, Microsoft Edge, Apple Safari, Opera
OR
Define tree topology. Also, write down any one limitation of tree topology
Ans: Tree topology is a network topology that combines characteristics of bus and star topologies, where groups of star-configured computers are connected to a central bus backbone.
Limitations: Failure of the main backbone cable can bring down the entire network. It is expensive because it requires a lot of cable and network devices.

SECTION C

29. 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.)
Ans:
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()
OR
Write a Python function that displays the number of times the word "Python" appears in a text file named "Prog.txt".
Ans:
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()

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.
Ans:
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. 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
Ans:
def Pop_element():
    while Books:
        print(Books.pop())
    print("Stack Empty")

31. 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.
Ans:
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))

OR

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.
print(output)
Ans: 
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))

SECTION D

32. Consider the table TECH_EVENT_REG as given below:
reg_idparticipant_nameevent_namegradereg_fee
501AaravHackathon11200
500RiyaRoboRace10150
503KrishWebDev Challange12250
504NavyaHackathon11200
505SamairaCodeSprint9100
506RohanRoboRace10150
Write the following queries:
I. To display the number of participants in each event where the number of participants is greater than 1.
Ans: select event_name, count(*) as total_participants from tech_event_reg group by event_name having count(*) > 1;
I. To display the distinct event names available in the Tech Event.
Ans: select distinct event_name from tech_event_reg;
III. To display details of participants whose names contain the letters ‘an’.
Ans: select * from tech_event_reg where participant_name like '%an%';
IV. To display all records of TECH_EVENT_REG sorted by participant_name in descending order.
Ans: select * from tech_event_reg order by participant_name desc;

OR

Predict the output of the following:
I. Select participant_name, event_name from tech_event_reg where grade = 11;
Ans:
participant_nameevent_name
AaravHackathon
NavyaHackathon

II. Select event_name, count(*) from tech_event_reg group by event_name;
Ans:
event_nameCOUNT(*)
Hackathon2
RoboRace2
WebDev Challenge1
CodeSprint1

III. Select participant_name from tech_event_reg where event_name like '%challenge';
Ans:
participant_name
Krish

IV. Select max(reg_fee) from tech_event_reg where grade in (9, 10);
Ans:
MAX(reg_fee)
150

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.
Ans:
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", newline="") as f:
        w = csv.writer(f)
        w.writerow([Vehicle_ID, Vehicle_Type, Hours_Rented, Rate_Per_Hour])
    print("Rental record added successfully.")

II. CalculateTotalRent() – to calculate and return the total rent earned (Hours_Rented × Rate_Per_Hour).
Ans:
def CalculateTotalRent():
    total = 0
    with open("Rentals.csv", "r") as f:
        r = csv.reader(f)
        for row in r:
            hours = int(row[2])
            rate = int(row[3])
            total += hours * rate
    return total

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_IDEvent_NameEvent_DateVenueMax_Participants
101Inter-School Chess Championship2025-01-15Auditorium Hall60
102Rapid Chess Tournament2025-02-10Activity Room 340
103Under-16 Chess Cup2025-03-05Sports Complex Room 250
104Teachers vs Students Chess Meet2025-04-12Library Conferemce Area30
105Open Blitz Chess Challenge2025-05-20IT Lab 180
Table: Registrations
Reg_IDStudent_NameClassEvent_IDRegistration_Date
1Aarav Singh9A1012024-12-20
2Navya Sharma9C1032025-01-12
3Rudransh Verma10B1022025-01-25
4Daksh Lal9B1042025-02-18
5Abhijay Malhotra11A1052024-03-30
6Krish Sharma10A1012025-12-22
7Manas Taneja8C1022025-01-28
8Riya Kapoor11B1052025-04-01
9Harsh Mehta12A1032025-02-20
10Simran Kaur9D1042025-03-05
I. Write a MySQL query to update the venue of the event "Inter-School Chess Championship" to "Multi-Purpose Hall".
Ans: UPDATE CHESS_EVENTS SET Venue = 'Multi-Purpose Hall' WHERE Event_Name = 'Inter-School Chess Championship';
II. Display the details of all chess events scheduled after 2025-01-01.
Ans: SELECT * FROM CHESS_EVENTS WHERE Event_Date > '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’.
Ans: SELECT * FROM REGISTRATIONS R JOIN CHESS_EVENTS C ON R.Event_ID = C.Event_ID WHERE C.Venue IN ('Auditorium Hall', 'Activity Room 3', 'Library Conference Area');
IV. (A) Display the student_name along with the event_name for all registrations.
Ans: SELECT R.Student_Name, C.Event_Name FROM REGISTRATIONS R JOIN CHESS_EVENTS C ON R.Event_ID = C.Event_ID;
OR
(B) Write a MySQL query to display the cartesian product of Chess_Event and Registrations tables.
Ans: SELECT * FROM CHESS_EVENTS, REGISTRATIONS;

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.
Ans:
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()

SECTION E

36. A college administrator, Atul, maintains student course enrollment records.
Each record includes Roll_No, Student_Name, Course, Fees.
Write Python functions to:
I. Input enrollment details and append them to a binary file.
Ans:
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]
    with open("Enrollments.dat", "ab") as f:
        pickle.dump(rec, f)
    print("Record added successfully.")
II. Update the Fees of all students enrolled in the "Data Science" course to 75000.
Ans:
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.")

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:
FromToDistance (in meters)
Law BlockBusiness Block90
Law BlockTechnology Block55
Law BlockHR Center120
Business BlockTechnology Block70
Business BlockHR Center105
Technology BlockHR Center45
Number of Computers in Each Block/Center are as follows:
BlockNumber of Computers
Law Block30
Technology Block55
HR Center120
Business Block45
I. Suggest the most suitable place (i.e. Block/Center) to install the server of this university with a suitable reason.
Ans: HR Centre as it has maximum number of computers.
II. Identify and draw the most suitable topology for connecting all the blocks if the university wants a centralized network management system.
Ans: Star Topology
CBSE-Class-12-CS-083-Sample-Question-Paper-2026-27-with-Solution-Q37
III. Suggest and placement of the following devices with reasons.
a) Repeater
b) Switch
Ans: a) Repeater is to be placed between Block IT to Block HR as distance between them is more than 100 metres.
b) Switch is to be placed in each and every building.
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.
Ans: Optical Fibre
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?
Ans: Voice over Internet Protocol (VoIP)
OR
(B) What is the use of VoIP?
Ans: 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.

Post a Comment

Previous Post Next Post