CBSE Class 12 · Computer Science 083 · Chapter by chapter

Class 12 computer science important questions, chapter wise, with answers.

These class 12 computer science important questions are sorted two ways: by chapter, so you can finish one topic at a time, and by marks, so you can practise only the three-mark programs on a given evening. All 57 are original. Cover the answer, write on paper, then open it.

57 questions, 1 to 5 marks · Python and MySQL answers run before printing · classes one to one, when you are free

Start here

Courses for the chapters you find hard

If the weak questions are spread across the bank, take the full Class 11 and 12 course. If they sit in one place, take the course that teaches that place from the start.

Ans. The short version

Class 12 computer science important questions for CBSE 083 come from seven chapters: functions with Class XI Python, exception handling, files, stack, computer networks, databases with SQL, and Python with MySQL. This page has 57 original questions of 1, 2, 3, 4 and 5 marks, chapter wise, with full answers and outputs that were run. CBSE issues no list of important questions, so these cover what the 2026-27 syllabus names. Modern Age Coders practises them live, personalised one to one at your own timing, and a priority demo lets you try a full class first.

Q1. Where should I begin?

Which questions are important for the Class 12 CS board exam?

The important questions are those that cover each topic named in the 083 syllabus, at the marks the paper uses: one, two, three, four and five. CBSE does not publish a list, and nobody can tell you the actual questions. Choose from the grid by chapter or by marks.

Chapter1 mark2 marks3 marks4 marks5 marks
1. Functions and Python revision1 to 34 to 910 to 12nonenone
2. Exception handling1314, 1516nonenone
3. Text, binary and CSV files17 to 1920 to 2223 to 252627, 28
4. Stack293031, 32nonenone
5. Computer networks33 to 3637 to 41nonenone42
6. Databases and SQL43 to 4546 to 48, 524950, 51, 53none
7. Python with MySQL5455none56, 57none

Short of time?

Do the longest question of each chapter: 12, 16, 27, 31, 42, 53 and 57. If one will not come, do the rest of that chapter before anything else.

Weak at programs?

Write 8, 10, 16, 23, 24, 26, 31 and 32 in that order. Each uses one idea more than the one before it.

Want MCQs or outputs?

They have pages of their own: the MCQ test and output questions.

Chapters 1 and 2

Important questions Class 12 CS: Python functions and exception handling

Functions are asked at one, two and three marks, usually on a list, a string or a dictionary from Class XI. Exception handling is a small chapter, and it returns inside every file program. The number in brackets is the marks.

Functions: one and two marks

  1. [1] Write one statement that stores in rev the words of the string line in reverse order, as a list.
    Answer rev = line.split()[::-1]. split() gives the list of words and the slice with step -1 reverses it. For "rain on tin" it gives ['tin', 'on', 'rain'].
  2. [1] A function begins def area(length, breadth=4):. Which of these calls are valid: area(3), area(), area(2, 5), area(1, 2, 3)?
    Answer area(3) and area(2, 5). The call with no argument misses the positional parameter length, and the call with three gives one too many. Both raise TypeError.
  3. [1] What are the least and greatest values that random.randint(2, 5) * 3 can give?
    Answer 6 and 15. randint() includes both ends, so the number is 2, 3, 4 or 5 before it is multiplied.
  4. [2] State the type of function in each call, choosing from built-in, defined in a module, user defined: len("CBSE"), math.sqrt(16), fee(3) after def fee(n):, random.random().
    Answer len() is built-in. math.sqrt() and random.random() are defined in modules, so the module has to be imported first. fee() is user defined. Half a mark each.
  5. [2] What is the difference between an argument and a parameter? Mark both in an example.
    Answer A parameter is the name in the function header that receives a value. An argument is the value supplied in the call. One mark for the difference, one for the example.
    Q5output 180
    def cost(pages, rate):      # pages and rate are parameters
        return pages * rate
    
    print(cost(60, 3))          # 60 and 3 are arguments
  6. [2] Predict the output and say why the last line is not 30.
    Q6scope
    level = 20
    
    def raise_level(level):
        level += 10
        print("inside", level)
    
    raise_level(level)
    print("outside", level)
    Answer inside 30, then outside 20. The parameter level is local to the function, so changing it leaves the global level alone. One mark for each line.
  7. [2] This function should take 10% off amounts of 1000 or more. Find four errors, rewrite the code and underline each correction.
    Q7four errors
    def bill(amount, rate=10)
        if amount => 1000:
            amount = amount - amount * rate / 100
        Return amount
    print("Pay", bill[1500])
    Answer
    Q7 correctedoutput Pay 1350.0
    def bill(amount, rate=10):              # 1. colon
        if amount >= 1000:                  # 2. >= not =>
            amount = amount - amount * rate / 100
        return amount                       # 3. small r
    print("Pay", bill(1500))                # 4. round brackets
    Half a mark for each correction.
  8. [2] Write a function swap_ends(items) that exchanges the first and last elements of a list. It must change the caller's list and return nothing.
    Answer
    Q8output [9, 4, 6, 2]
    def swap_ends(items):
        items[0], items[-1] = items[-1], items[0]
    
    tiles = [2, 4, 6, 9]
    swap_ends(tiles)
    print(tiles)
    A list is mutable, so the function works on the very list the caller holds. If you print the call itself, you get None.
  9. [2] Predict the output.
    Q9returning two values
    def parts(n):
        return n // 10, n % 10
    
    tens, ones = parts(47)
    print(ones, tens)
    print(parts(82)[1] + 5)
    Answer First line 7 4: the function returns a tuple (4, 7), which is unpacked. Second line 7: item 1 of (8, 2) is 2, and 2 + 5 is 7.

Functions: three marks

  1. [3] Write a function word_lengths(sentence) that returns a dictionary with each word length as the key and the number of words of that length as the value.
    Answer
    Q10output {2: 5, 3: 1}
    def word_lengths(sentence):
        counts = {}
        for word in sentence.split():
            size = len(word)
            counts[size] = counts.get(size, 0) + 1
        return counts
    
    print(word_lengths("to be or not to be"))
    get(size, 0) returns 0 the first time a length is seen, so no separate if is needed.
  2. [3] Write a function split_marks(marks, cutoff=33) that returns two lists, the marks at or above the cutoff and the marks below it. Show a call with and a call without the second argument.
    Answer
    Q11two return values
    def split_marks(marks, cutoff=33):
        above, below = [], []
        for mark in marks:
            if mark >= cutoff:
                above.append(mark)
            else:
                below.append(mark)
        return above, below
    
    print(split_marks([71, 28, 33, 45]))
    print(split_marks([71, 28, 33, 45], 40))
    
    # Output:
    # ([71, 33, 45], [28])
    # ([71, 45], [28, 33])
    Half a mark for the header, two for the logic, half for the return.
  3. [3] A courier charges 50 for the first 2 kg, then 20 for each further kilogram or part of one. Write charge(weight) to return the amount. For 2 it returns 50, and for 4.5 it returns 110.
    Answer
    Q12output 50, then 110
    import math
    
    def charge(weight):
        if weight <= 2:
            return 50
        extra = math.ceil(weight - 2)   # 2.5 becomes 3
        return 50 + extra * 20
    
    print(charge(2))
    print(charge(4.5))
    ceil() handles "or part of one". With int() the answer for 4.5 kg would be 90.

Exception handling

  1. [1] Can a try block be followed by a finally block with no except block?
    Answer Yes. The finally block runs, and if an exception occurred it is then raised again, since nothing caught it.
  2. [2] Name the exception raised by each: int("12a"), [4, 5][2], open("none.txt") when the file is absent, "5" + 5.
    Answer ValueError, IndexError, FileNotFoundError, TypeError. Half a mark each.
  3. [2] Predict the output of the two calls.
    Q15flow of control
    def share(sweets, children):
        try:
            print(sweets // children)
        except ZeroDivisionError:
            print("no children")
        finally:
            print("done")
    
    share(17, 5)
    share(17, 0)
    Answer 3, done, no children, done, one to a line. In the second call the division fails, so nothing is printed from try and control goes to except. The finally block runs both times.
  4. [3] Write a function read_marks() that keeps asking until the user types a whole number from 0 to 100, and then returns it. Text must not stop the program.
    Answer
    Q16input until valid
    def read_marks():
        while True:
            try:
                marks = int(input("Marks: "))
                if 0 <= marks <= 100:
                    return marks
                print("Use 0 to 100")
            except ValueError:
                print("Type a whole number")
    
    print("Saved", read_marks())
    We typed ninety, then 140, then 88. It printed Type a whole number, Use 0 to 100 and Saved 88. One mark for try and except, one for the range, one for the loop and the return.

Chapter notes: functions and exception handling.

Chapter 3

File handling questions: text, binary and CSV

Expect file questions at every mark level. The safest habit is to write the with line first, with the mode, and only then think about the loop.

One and two marks

  1. [1] Which mode lets a program add lines to the end of a text file and also read it, without erasing it?
    Answer a+. Move the pointer with seek(0) before reading, because the file opens at its end.
  2. [1] Say whether each path is relative or absolute: data/marks.txt and C:/school/marks.txt.
    Answer The first is relative: it starts from the current folder. The second is absolute: it starts from the drive and names every folder.
  3. [1] A text file holds "Namaste India". After f.read(6), what does f.tell() give?
    Answer 6. Six characters have been read, so the pointer stands before the seventh, the letter e.
  4. [2] Give two differences between a text file and a binary file.
    Answer A text file stores characters arranged in lines and can be read in any editor; a binary file stores bytes in the form the program uses and looks meaningless in an editor. Text needs decoding and has a newline at the end of each line; a binary file of Python objects is read back with the pickle module. One mark each.
  5. [2] What is the difference between write() and writelines()? Give an example of each.
    Answer write() takes one string. writelines() takes a list of strings. Neither adds a newline for you.
    Q21output: Ragi, Bajra and Jowar on three lines
    with open("grain.txt", "w") as f:
        f.write("Ragi\n")
        f.writelines(["Bajra\n", "Jowar\n"])
    
    with open("grain.txt", "r") as f:
        print(f.read())
  6. [2] Predict the output if word.txt holds COMPUTER.
    Q22seek and tell
    with open("word.txt", "r") as f:
        f.seek(3)
        print(f.read(2))
        print(f.tell())
        f.seek(0)
        print(f.read(1))
    Answer PU, 5, C. The pointer is moved to index 3, two characters are read, so it stands at 5. Then it returns to the start.

Three marks

  1. [3] Write a function number_lines() that copies Speech.txt to Numbered.txt with a line number, a dot and a space before each line.
    Answer
    Q23text to text
    def number_lines():
        count = 0
        with open("Speech.txt", "r") as source:
            with open("Numbered.txt", "w") as target:
                for line in source:
                    count += 1
                    target.write(str(count) + ". " + line)
    
    number_lines()
    From the lines Good morning, Dear friends and Thank you, Numbered.txt held 1. Good morning, 2. Dear friends and 3. Thank you. The newline travels with each line, so none is added.
  2. [3] Write a function questions() that displays every line of Interview.txt that ends with a question mark, and returns how many there were.
    Answer
    Q24strip before testing
    def questions():
        count = 0
        with open("Interview.txt", "r") as f:
            for line in f:
                line = line.strip()         # remove the newline
                if line.endswith("?"):
                    print(line)
                    count += 1
        return count
    
    print(questions())
    With What is a tuple? / It is a sequence. / Can it change? on three lines, it printed the first and third, then 2. Without strip() the last character is the newline, and the test fails.
  3. [3] Songs.dat holds dictionaries with the keys title and minutes, one per dump. Write copy_long(limit) to copy the records with minutes above the limit into Long.dat and return how many were copied.
    Answer
    Q25binary to binary
    import pickle
    
    def copy_long(limit):
        copied = 0
        with open("Songs.dat", "rb") as source:
            with open("Long.dat", "wb") as target:
                try:
                    while True:
                        song = pickle.load(source)
                        if song["minutes"] > limit:
                            pickle.dump(song, target)
                            copied += 1
                except EOFError:
                    pass
        return copied
    With Barsaat 4, Nadi 7 and Pahaad 6 in the file, copy_long(5) returned 2.

Four and five marks

  1. [4] A repair shop keeps Repairs.csv with a heading row and the columns JobNo, Device, Cost. Write (I) create(rows) to write the heading and all the rows given as a list of lists; (II) costly(limit) to display the job number and device of every job costing more than the limit, and then how many there were.
    Answer
    Q26CSV with a heading
    import csv
    
    def create(rows):
        with open("Repairs.csv", "w", newline="") as f:
            w = csv.writer(f)
            w.writerow(["JobNo", "Device", "Cost"])
            w.writerows(rows)
    
    def costly(limit):
        count = 0
        with open("Repairs.csv", "r", newline="") as f:
            r = csv.reader(f)
            next(r)                         # step over the heading
            for row in r:
                if int(row[2]) > limit:
                    print(row[0], row[1])
                    count += 1
        print("Costly jobs:", count)
    
    create([["J1", "Phone", 900], ["J2", "Laptop", 3200], ["J3", "Tablet", 1800]])
    costly(1500)
    
    # Output:
    # J2 Laptop
    # J3 Tablet
    # Costly jobs: 2
    Two marks for each function. Leave out next(r) and the program stops with a ValueError, because the word Cost cannot become a number.
  2. [5] A nursery stores each plant in Nursery.dat as a dictionary with the keys pid, name and qty. Write functions (I) add_plant() to accept a plant and append it; (II) find_plant(pid) to display the name and quantity of that plant, or "Not found". (2 + 3)
    Answer
    Q27append and search
    import pickle
    
    def add_plant():
        plant = {}
        plant["pid"] = int(input("Plant id: "))
        plant["name"] = input("Name: ")
        plant["qty"] = int(input("Quantity: "))
        with open("Nursery.dat", "ab") as f:
            pickle.dump(plant, f)
    
    def find_plant(pid):
        found = False
        try:
            with open("Nursery.dat", "rb") as f:
                while True:
                    plant = pickle.load(f)
                    if plant["pid"] == pid:
                        print(plant["name"], plant["qty"])
                        found = True
        except EOFError:
            pass
        if not found:
            print("Not found")
    We added 21 Tulsi 40 and 22 Neem 15. find_plant(22) printed Neem 15 and find_plant(30) printed Not found. "Not found" must come after the whole file has been read; inside the loop it would print once for every plant that does not match.
  3. [5] Pools.dat holds lists [area, level], one per dump, where level is in centimetres. Write (I) show_all() to display every record; (II) rain(cm) to add the given centimetres to every level below 100 and save the file. (2 + 3)
    Answer
    Q28read, change, rewrite
    import pickle
    
    def show_all():
        try:
            with open("Pools.dat", "rb") as f:
                while True:
                    print(pickle.load(f))
        except EOFError:
            pass
    
    def rain(cm):
        pools = []
        try:
            with open("Pools.dat", "rb") as f:
                while True:
                    pool = pickle.load(f)
                    if pool[1] < 100:
                        pool[1] += cm
                    pools.append(pool)
        except EOFError:
            pass
        with open("Pools.dat", "wb") as f:
            for pool in pools:
                pickle.dump(pool, f)
    With ["North", 80], ["East", 120] and ["West", 95] stored, rain(10) and then show_all() gave ['North', 90], ['East', 120] and ['West', 105]. The reading must be finished before the file is opened with wb, which empties it.

The chapters behind these: text file handling and CSV and binary files.

Chapters 4 and 5

Stack and computer networks: questions with answers

The stack is always a Python list in this syllabus, with push and pop. Networks need exact words more than long answers.

Stack

  1. [1] An empty stack gets push 5, push 8, pop, push 3, pop, pop. What is left, and what would one more pop be called?
    Answer Nothing is left. One more pop is an underflow.
  2. [2] A stack S is a list whose top is the last element. Write (a) the statement that pushes x, (b) the statement that pops into y, (c) the condition that must be true before (b) runs, (d) an expression for the number of elements.
    Answer (a) S.append(x) (b) y = S.pop() (c) len(S) > 0, or simply S (d) len(S). Half a mark each.
  3. [3] A dictionary holds cities and temperatures: temps = {"Jaipur": 43, "Shimla": 22, "Nagpur": 45, "Kochi": 31}. Write push_hot() to push the names of cities above 40 on the stack Hot, and pop_hot() to pop and display them all, then "Stack empty".
    Answer
    Q31dictionary to stack
    temps = {"Jaipur": 43, "Shimla": 22, "Nagpur": 45, "Kochi": 31}
    Hot = []
    
    def push_hot():
        for city in temps:
            if temps[city] > 40:
                Hot.append(city)
    
    def pop_hot():
        while len(Hot) > 0:
            print(Hot.pop())
        print("Stack empty")
    
    push_hot()
    pop_hot()
    
    # Output:
    # Nagpur
    # Jaipur
    # Stack empty
    One and a half marks for each function.
  4. [3] Using a stack, write a function reverse_words(sentence) that returns the sentence with its words in reverse order.
    Answer
    Q32output: lamp the light
    def reverse_words(sentence):
        stack = []
        for word in sentence.split():
            stack.append(word)          # push
        result = ""
        while stack:
            result += stack.pop() + " " # pop, last word first
        return result.strip()
    
    print(reverse_words("light the lamp"))
    The question says "using a stack", so reverse() or a slice would not answer it.

More of these: stack in Python for Class 12.

Computer networks

  1. [1] Expand VoIP and PPP.
    Answer Voice over Internet Protocol and Point to Point Protocol.
  2. [1] Which device changes digital signals to analog and back, so that a computer can use a telephone line?
    Answer A modem, short for modulator and demodulator.
  3. [1] Pick out the domain name in https://library.example.org/new/books.html.
    Answer library.example.org. The part before it is the protocol, and the part after it is the path of the page.
  4. [1] A student sends photographs from a phone to a laptop in the same room by Bluetooth. What type of network is it?
    Answer PAN, a personal area network.
  5. [2] Write two differences between circuit switching and packet switching.
    Answer In circuit switching a path is fixed before the transfer begins and stays reserved until it ends; in packet switching the message is cut into packets that may travel by different routes. Circuit switching wastes the path during silence, as in a telephone call; packet switching shares it, and the packets are put in order at the destination.
  6. [2] Give two advantages of fiber-optic cable over twisted pair cable, and one disadvantage.
    Answer It carries data at a much higher rate over a longer distance, and electrical interference does not disturb it. It costs more and is harder to join. Half a mark for each point, and half for being clear which side each belongs to.
  7. [2] Differentiate between a web browser and a web server, with an example of each.
    Answer A web browser is a program on the user's computer that requests pages and displays them, such as Firefox. A web server stores websites and sends pages when they are requested, such as Apache.
  8. [2] What do bandwidth and data transfer rate measure? Give the unit of each.
    Answer Bandwidth is the range of frequencies a channel can carry, measured in hertz. Data transfer rate is the amount of data sent in one second, measured in bits per second.
  9. [2] What is web hosting, and why does a school website need it?
    Answer Web hosting is keeping a website's files on a web server that stays connected to the internet. Without it, the pages would exist only on the computer where they were made, and nobody could open them through the URL.
  10. [5] A wildlife research centre has four buildings: Lab (25 computers), Hostel (60), Museum (40) and Gate (10). Distances: Lab to Hostel 70 m, Lab to Museum 130 m, Lab to Gate 90 m, Hostel to Museum 80 m, Hostel to Gate 110 m, Museum to Gate 160 m. (I) Where should the server be placed, and why? (II) Suggest a topology in which every building joins the server building by its own cable. (III) On which cable of that layout is a repeater needed? (IV) Name the device needed in every building to join its computers. (V) Which protocol should the Lab use to send large video files to the server?
    Answer (I) Hostel, which has the most computers, so most of the traffic stays local. (II) Star, with Hostel at the centre: cables of 70 m to Lab, 80 m to Museum and 110 m to Gate. (III) Hostel to Gate, since 110 m is above 100 m. (IV) A switch. (V) FTP. One mark for each part.

Notes and tables: computer networks. Longer situations: case study questions.

Chapter 6

Databases and SQL: important questions for Class 12 computer science

SQL questions are won on small words: IS NULL, HAVING, DISTINCT, and the join condition. The answers below were run on MySQL (version 26.10), and the grids are printed as it returned them.

Concepts and commands

  1. [1] A table has 4 columns and 6 rows. Two rows are inserted and one column is removed. Give the new degree and cardinality.
    Answer Degree 3, cardinality 8.
  2. [1] Which clause removes repeated values from the result of a SELECT?
    Answer DISTINCT, as in SELECT DISTINCT Host FROM PODCAST;
  3. [1] What does the domain of an attribute mean? Give one example.
    Answer The set of values the attribute may take. For a column Month holding numbers, the domain is 1 to 12.
  4. [2] Sort these commands into DDL and DML: ALTER, UPDATE, DROP, INSERT, CREATE, DELETE, SELECT.
    Answer DDL: ALTER, DROP, CREATE, which work on the structure. DML: UPDATE, INSERT, DELETE, SELECT, which work on the rows.
  5. [2] Differentiate between ORDER BY and GROUP BY, with an example of each.
    Answer ORDER BY sorts the rows of the result and keeps every row. GROUP BY gathers rows with the same value into one row, usually with an aggregate function. SELECT Title FROM PODCAST ORDER BY Minutes; lists six titles; SELECT Host, COUNT(*) FROM PODCAST GROUP BY Host; lists three hosts.
  6. [2] Write a command to create SAPLING with TagNo (integer, primary key), Species (up to 20 characters, must not be empty), Planted (date) and Height (decimal).
    Answer
    Q48half a mark for each column
    CREATE TABLE SAPLING (
        TagNo INT PRIMARY KEY,
        Species VARCHAR(20) NOT NULL,
        Planted DATE,
        Height FLOAT
    );
  7. [3] For the table SAPLING, write commands to (I) add a column Ward of 3 characters, (II) remove the primary key, (III) remove the column Height.
    Answer
    Q49one mark each
    ALTER TABLE SAPLING ADD Ward CHAR(3);
    ALTER TABLE SAPLING DROP PRIMARY KEY;
    ALTER TABLE SAPLING DROP COLUMN Height;
    Removing the primary key does not remove the column TagNo; only the constraint goes.

Table PASS

PNoStudentRNoMonths
501Tara116
502Moin133
503Esha1112
504Joel123
505Vani136

Table ROUTE

RNoStartFare
11Lakeside900
12Old Town750
13Hilltop1100
14Riverbank800

More tables to query: SQL questions for Class 12 CS.

Table PODCAST

EIDTitleHostTopicMinutesPlays
E1Night SkyIraScience321200
E2Old CoinsDevHistory45800
E3Deep SeaIraScience28NULL
E4Fort WalksZoyaHistory511500
E5RagasDevMusic38950
E6Rock PoolsZoyaScience401100

Queries on these tables

  1. [4] Write queries on PODCAST: (I) the average minutes for each topic that has more than one episode; (II) the title and host of episodes whose plays are not recorded; (III) the title and plays of episodes of 30 to 45 minutes, most played first; (IV) the different hosts of episodes that are not on Science.
    Answer
    Q50one mark each
    SELECT Topic, AVG(Minutes) FROM PODCAST
    GROUP BY Topic HAVING COUNT(*) > 1;
    
    SELECT Title, Host FROM PODCAST WHERE Plays IS NULL;
    
    SELECT Title, Plays FROM PODCAST
    WHERE Minutes BETWEEN 30 AND 45 ORDER BY Plays DESC;
    
    SELECT DISTINCT Host FROM PODCAST WHERE Topic <> 'Science';
    Output of I and IIIMySQL
    +---------+--------------+
    | Topic   | AVG(Minutes) |
    +---------+--------------+
    | Science |      33.3333 |
    | History |      48.0000 |
    +---------+--------------+
    
    +------------+-------+
    | Title      | Plays |
    +------------+-------+
    | Night Sky  |  1200 |
    | Rock Pools |  1100 |
    | Ragas      |   950 |
    | Old Coins  |   800 |
    +------------+-------+
    (II) gives Deep Sea, Ira. (IV) gives Dev and Zoya. Writing Plays = NULL in (II) returns nothing at all.
  2. [4] Predict the output of each query on PODCAST.
    (I) SELECT COUNT(*), COUNT(Plays) FROM PODCAST;
    (II) SELECT Host, MAX(Minutes) FROM PODCAST GROUP BY Host;
    (III) SELECT Title FROM PODCAST WHERE Title LIKE '%o%s';
    (IV) SELECT Topic, SUM(Plays) FROM PODCAST WHERE Minutes < 45 GROUP BY Topic;
    Answer
    Q51 outputsMySQL
    +----------+--------------+
    | COUNT(*) | COUNT(Plays) |
    +----------+--------------+
    |        6 |            5 |
    +----------+--------------+
    
    +------+--------------+
    | Host | MAX(Minutes) |
    +------+--------------+
    | Ira  |           32 |
    | Dev  |           45 |
    | Zoya |           51 |
    +------+--------------+
    
    +------------+
    | Title      |
    +------------+
    | Old Coins  |
    | Fort Walks |
    | Rock Pools |
    +------------+
    
    +---------+------------+
    | Topic   | SUM(Plays) |
    +---------+------------+
    | Science |       2300 |
    | Music   |        950 |
    +---------+------------+
    In (III) the title needs an o somewhere and an s at the end; MySQL matched the capital O of Old Coins. In (IV) History has no episode under 45 minutes, so it has no group, and the NULL of Deep Sea is skipped by SUM.
  3. [2] How many rows and columns are in (a) the Cartesian product of PASS and ROUTE (b) their natural join? Name the route missing from (b) and say why.
    Answer (a) 5 times 4 is 20 rows, and 4 plus 3 is 7 columns. (b) 5 rows and 6 columns, since RNo appears once. Route 14, Riverbank, is missing because no pass has its number.
  4. [4] Write queries: (I) reduce the fare by 50 for every route whose starting point ends in "side"; (II) display the student and starting point for passes on routes with a fare above 800; (III) display pass number, student and Fare times Months, headed Amount, using a natural join; (IV) display each route number that has two or more passes, with the number of passes.
    Answer
    Q53one mark each
    UPDATE ROUTE SET Fare = Fare - 50 WHERE Start LIKE '%side';
    
    SELECT Student, Start FROM PASS, ROUTE
    WHERE PASS.RNo = ROUTE.RNo AND Fare > 800;
    
    SELECT PNo, Student, Fare * Months AS Amount
    FROM PASS NATURAL JOIN ROUTE;
    
    SELECT RNo, COUNT(*) FROM PASS
    GROUP BY RNo HAVING COUNT(*) >= 2;
    Output of IIIMySQL, on the fares printed above
    +-----+---------+--------+
    | PNo | Student | Amount |
    +-----+---------+--------+
    | 501 | Tara    |   5400 |
    | 502 | Moin    |   3300 |
    | 503 | Esha    |  10800 |
    | 504 | Joel    |   2250 |
    | 505 | Vani    |   6600 |
    +-----+---------+--------+
    (I) changes one row, Lakeside, to 850. (II) gives Tara, Moin, Esha and Vani, with or without that change. (IV) gives 11 and 13, with 2 passes each.

Chapter 7, and how to use all seven

Python with MySQL questions, and how to practise the whole bank

Connectivity is the most predictable program in the paper: import, connect, cursor, execute, commit or fetch, close. Learn the order once and only the query changes.

  1. [1] After a SELECT that matches four rows, fetchone() is called once and then fetchall(). How many rows does fetchall() return, and in what form?
    Answer Three, as a list of tuples. The first row was already taken by fetchone().
  2. [2] Four lines of this program are wrong. Correct them.
    Q55find four errors
    import mysql.connector
    con = mysql.connect(host="localhost", user="root",
                        password="your_password", database="HostelDB")
    cur = con.cursor
    cur.execute("UPDATE LOCKER SET Holder = %s WHERE LNo = %s", "Ayaan", 7)
    cur.commit()
    con.close()
    Answer (1) mysql.connector.connect(...). (2) con.cursor(), with brackets. (3) the values go in one tuple: ("Ayaan", 7). (4) con.commit(): commit belongs to the connection. Half a mark each.
  3. [4] The MySQL database HostelDB has the table LOCKER (LNo integer primary key, Holder string, FloorNo integer). Write a Python program that accepts the details of one locker from the user and inserts them. User root, host localhost.
    Answer
    Q56INSERT needs commit
    import mysql.connector
    
    con = mysql.connector.connect(host="localhost", user="root",
                                  password="your_password", database="HostelDB")
    cur = con.cursor()
    
    number = int(input("Locker number: "))
    holder = input("Holder: ")
    floor_no = int(input("Floor: "))
    
    query = "INSERT INTO LOCKER VALUES (%s, %s, %s)"
    cur.execute(query, (number, holder, floor_no))
    con.commit()
    print("Rows added:", cur.rowcount)
    
    cur.close()
    con.close()
    We entered 7, Ayaan and 2. It printed Rows added: 1, and the row was in the table afterwards.
  4. [4] For the same table, write a program that asks for a floor number, displays the lockers on that floor, then deletes them and says how many were deleted, or "No locker on that floor".
    Answer
    Q57SELECT, then DELETE
    import mysql.connector
    
    con = mysql.connector.connect(host="localhost", user="root",
                                  password="your_password", database="HostelDB")
    cur = con.cursor()
    
    floor_no = int(input("Floor: "))
    cur.execute("SELECT * FROM LOCKER WHERE FloorNo = %s", (floor_no,))
    for row in cur.fetchall():
        print(row)
    
    cur.execute("DELETE FROM LOCKER WHERE FloorNo = %s", (floor_no,))
    con.commit()
    if cur.rowcount > 0:
        print("Deleted:", cur.rowcount)
    else:
        print("No locker on that floor")
    
    cur.close()
    con.close()
    With lockers (7, 'Ayaan', 2), (8, 'Meher', 2) and (9, 'Rudra', 3) stored, typing 2 printed both rows of floor 2 and Deleted: 2. Typing 5 printed No locker on that floor. The comma in (floor_no,) makes it a tuple.

All the patterns: Python MySQL connectivity.

Four rounds through the bank

  1. Round one: chapter by chapter

    Answer in writing. Put a cross beside anything you could not finish, and do not stop to study it yet.

  2. Round two: crosses only

    Read the chapter page for each cross, then answer again with the book closed.

  3. Round three: by marks

    All the three-mark questions in one sitting, then the fours and fives. This is how the paper feels.

  4. Round four: change one thing

    Alter each program yourself: a new condition, a new file, records as lists and not dictionaries. If it still runs, the question is yours.

After round four, write a complete practice paper and read how step marks are given. For complete listings to type and run, there are 20 Python programs for Class 12.

In a live class. The teacher picks three questions from your crosses. You write, the program is run as you wrote it, and then the question is changed on the spot to see whether you learnt the method or the answer.

One to one, at your own timing

Practise the questions you cannot finish alone

You bring the crosses, and a teacher works through them with you and nobody else. Classes are personalised one to one, on the days and at the time you choose. To see whether it suits you, take a priority demo at a slot of your choice, with its fee set against your first month if you enrol, or a free demo class. Payment is monthly, nothing is charged for admission, and you can leave at the end of any month.

Before you enrol · Try a class

Priority demo, at a slot you pick

a full live class of about 45 to 60 minutes

  • Three questions from three chapters, answered in front of the teacher
  • Each answer run or checked, then altered to test the idea
  • The chapter that slows you down is named and begun
  • A written skill report after the class, chapter by chapter
Book a priority demo

The classes · Choose your own timing

Personalised one to one

₹4,999

per month, 4 private classes, fully flexible timing

  • Questions chosen from your own weak chapters
  • Programs written by hand first, then run
  • Fresh questions when you start to remember the old ones
  • School tests, practicals and the board paper in one plan
Ask for a personalised plan

There is no fixed order of chapters. A student who is sure of Python and lost in SQL starts with SQL. The fee is shown on this page in your own currency.

Studying outside India?

Question practice for 083 students abroad

CBSE students in Sharjah, Jeddah or Kuala Lumpur answer the same kind of paper, so this bank is theirs as well. The class hour is set by your evening.

Where you liveTime differenceUsual class window, local timeFormat
India
every Indian city
Indian timeAny time you choosePersonalised 1-on-1
UAE and Oman
Dubai, Abu Dhabi, Sharjah, Muscat
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Saudi Arabia, Qatar, Kuwait, Bahrain
Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama
2 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Nepal
Kathmandu
15 min ahead of India4:30 PM to 9:00 PMPersonalised 1-on-1
Ethiopia and East Africa
Addis Ababa and East Africa Time
2 h 30 min behind India4:30 PM to 9:00 PMPersonalised 1-on-1
Singapore and Malaysia
Singapore, Kuala Lumpur
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1

Send a photograph of a written answer before the class if you like, and the teacher will have read it by the time you meet.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 12 series

More pages for Class 12 students

Every page in the CBSE Class 12 Computer Science series, grouped by what you need.

Questions about this bank

What students ask about important questions in Class 12 CS

Which are the most important questions in Class 12 Computer Science?

CBSE does not name any. Going by the shapes in the 2026-27 sample paper, prepare a text file program, a stack program, a CSV program, a binary file program, SQL on one and on two tables, a Python with MySQL program and a network case. This bank has originals of each, with shorter questions around them.

Are these important questions chapter wise?

Yes. They run through seven chapters in syllabus order: functions with Class XI Python, exception handling, files, stack, computer networks, databases and SQL, and Python with MySQL. A grid at the top also sorts them by marks, from 1 to 5, so you can practise either way.

Can I get Class 12 Computer Science important questions as a PDF?

We do not offer a PDF. The questions and answers are open on this page, without a login. Writing answers by hand with the solution folded away is better practice than reading a printed list, because the board paper asks you to write code and not to recognise it.

Are these previous year questions?

No. Every question here is original, written to the 2026-27 syllabus in the mark bands of the sample paper. Past papers are on the CBSE website, and they are worth solving too. Check each old question against the current syllabus before you spend time on it.

How many Python programs should I prepare for the Class 12 board exam?

There is no set number. Prepare types, not a list: a function on a list or dictionary, line-by-line and word-by-word text reading, binary append, search and update, CSV write and read, stack push and pop, and one connectivity program each for insert, update, delete and display.

Which chapter has the most marks in Class 12 Computer Science?

By unit, Computational Thinking and Programming 2 is 40 of the 70 marks, Database Management 20 and Computer Networks 10. CBSE does not fix marks below the unit. In the 2026-27 sample paper, file handling questions added up to 13 marks.

Are 5 mark questions compulsory in Class 12 Computer Science?

Yes, all 37 questions are compulsory. In the 2026-27 sample paper the two five-mark questions were a binary file program, which had no choice, and a network case, which had a choice in its last part. Questions 27, 28 and 42 here are of those kinds.

Can I pass SQL questions without learning joins?

You would be giving marks away. The syllabus lists Cartesian product, equi-join and natural join on two tables, and the sample paper has a four-mark question on two tables. Learn one pattern well: both tables after FROM, and the common column matched in WHERE.

Is recursion important for Class 12 Computer Science?

It is not in the 083 syllabus for 2026-27, so there are no recursion questions here. Queues, linked lists and SQL subqueries are not listed either. If an older question bank includes them, leave those questions out.

How do I get help with the questions I cannot solve?

Modern Age Coders teaches live, personalised one to one classes at your own days and timing, built on the questions you marked as unfinished. Start with a priority demo, a full class of about 45 to 60 minutes followed by a written skill report, its fee adjusted if you enrol. A free demo class is available as well.

Start

Send three questions you could not finish

Put their numbers in the message. In the free demo class the teacher takes one of them and works it with you until you can do a changed version alone.

For all three, and a fuller look at your chapters, choose a priority demo at a slot that suits you. It is a full live class with a written skill report afterwards, and the fee is adjusted against the first month if you carry on.

Rather revise first? Class 12 CS notes has each topic in short form.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here