CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →
Free Resource · Class 12 · 083

CBSE Class 12 Computer Science Important Questions with Solutions

Kwickprep's free CBSE Class 12 Computer Science (083) important-questions guide for the 2026-27 session: the questions that repeat every year in Python functions, file handling, stack, SQL and Python-MySQL, each with a model answer and code.

Studying Class 12 Computer Science? Learn it live with Kwickprep.
Live one-to-one or small-batch classes with Kajal Ma'am — full board strategy, practical file, project and viva. 100% pass record, 100/100 toppers.
See the Class 12 Computer Science courseBook a free demo

These are the questions that repeat every year in CBSE Class 12 Computer Science (083), grouped by topic, each with a model answer. They cover most of the 40-mark Unit 1 (Python) and the 20-mark Database Management unit. For the exact board questions, always cross-check with the official CBSE sample paper and marking scheme.

{ }

Python functions output & scope

Predict the output (mutable default argument):

def change(x, lst=[]):
    lst.append(x)
    return lst

print(change(1))
print(change(2))

Solution: The output is [1] then [1, 2]. The default list is created only once when the function is defined and is shared across every call, so the second call keeps the first call's value. This is a favourite 2-mark trap.

Predict the output (global vs local scope):

x = 10
def f():
    x = 20
    print(x)
f()
print(x)

Solution: The output is 20 then 10. Assigning x = 20 inside the function creates a new local variable; the global x is unchanged. To change the global inside the function you must write global x first.

{ }

File handling text, binary & CSV

Write a function to count the lines in "story.txt" that begin with the letter 'A'.

def countA():
    f = open("story.txt", "r")
    count = 0
    for line in f:
        if line[0] == 'A':
            count += 1
    f.close()
    print(count)

Solution: Open the file in read mode, loop through each line and test its first character. Text-file read/write functions are a guaranteed 3–4 mark question.

Write a function to search a binary file "stu.dat" (records stored as [rollno, name, marks] with pickle) and display the record for a given roll number.

import pickle
def search(r):
    f = open("stu.dat", "rb")
    try:
        while True:
            rec = pickle.load(f)
            if rec[0] == r:
                print(rec)
    except EOFError:
        f.close()

Solution: Use pickle.load() inside a loop and stop on EOFError. Binary-file search/update with pickle is a common 4–5 mark question.

Write a function to add a record [rollno, name] to a CSV file "data.csv".

import csv
def addRec(rollno, name):
    f = open("data.csv", "a", newline="")
    w = csv.writer(f)
    w.writerow([rollno, name])
    f.close()

Solution: Open the file in append mode with newline="", create a csv.writer and call writerow(). The newline="" argument prevents blank rows and is often worth a mark.

{ }

Data structure Stack

Write push() and pop() functions to implement a stack using a list.

def push(stk, item):
    stk.append(item)

def pop(stk):
    if stk == []:
        return "Underflow"
    return stk.pop()

Solution: A stack is Last-In-First-Out. append() pushes to the top and pop() removes from the top. Always check for underflow (empty stack) before popping.

{ }

SQL queries

Table EMP(Eno, Name, Dept, Salary). Show each department and its employee count, only for departments with more than 2 employees.

Solution: SELECT Dept, COUNT(*) FROM EMP GROUP BY Dept HAVING COUNT(*) > 2; — GROUP BY groups rows by department and HAVING filters the grouped result. WHERE cannot be used with an aggregate like COUNT; that is the trick being tested.

Display the names of all employees in descending order of salary.

Solution: SELECT Name FROM EMP ORDER BY Salary DESC; — ORDER BY sorts the result; DESC makes it high-to-low (ASC or nothing is low-to-high).

{ }

Python-MySQL connectivity

Write code to fetch and display all rows of the table "student" from the MySQL database "school".

import mysql.connector
con = mysql.connector.connect(host="localhost",
    user="root", passwd="pw", database="school")
cur = con.cursor()
cur.execute("SELECT * FROM student")
for row in cur.fetchall():
    print(row)
con.close()

Solution: Connect with mysql.connector.connect(), create a cursor, run the query with execute(), then loop over fetchall(). Connectivity is a reliable 4–5 mark question in the Database unit.

{ }

Computer Networks short answers

Difference between a hub and a switch: a hub broadcasts incoming data to every connected device, while a switch sends it only to the specific destination device, so a switch is faster and more secure.

Difference between XML and HTML: HTML is a fixed markup language for displaying data with predefined tags; XML is extensible, has user-defined tags and is used to store and carry data.

Common expansions to memorise: URL — Uniform Resource Locator, FTP — File Transfer Protocol, SMTP — Simple Mail Transfer Protocol, VoIP — Voice over Internet Protocol, HTTP — HyperText Transfer Protocol.

{ }

Common questions

What are the most important questions in CBSE Class 12 Computer Science (083)?+
The most repeated, highest-scoring questions come from Python file handling (text, binary/pickle and CSV files), Python user-defined functions and scope, the Stack data structure using a list, SQL queries (GROUP BY, HAVING, ORDER BY, aggregate functions and joins) and Python-MySQL connectivity. Together these cover most of the 40-mark Unit 1 and the 20-mark Database Management unit.
Are these important questions enough to score 90+?+
They cover where most marks sit, but pair them with the official CBSE 2025-26 sample paper and marking scheme and complete the 30-mark practical (file, project and viva). At Kwickprep, Kajal Ma'am solves these questions live with the marking scheme in a free demo.
Where can I get the exact board questions?+
Use the official CBSE sample paper and marking scheme from cbseacademic.nic.in, linked on our Class 12 Computer Science sample paper page.

Want the full paper solved with you?

See a real class free, we walk through the sample paper, the scoring topics and your weak areas with Kajal Ma'am.

Book a free demo on WhatsApp