---
title: "Class 12 Computer Science MCQ with Answers: 40 Questions"
description: "Class 12 computer science MCQ with answers for CBSE 083: a 40-question test, chapter wise, with assertion reason items, a reason for each and a score table."
canonical: https://learn.modernagecoders.com/cbse-class-12-computer-science-mcq-test
source: src/pages/cbse-class-12-computer-science-mcq-test.html
updated: 2026-11-22
---

> Class 12 computer science MCQs with answers are the quickest check of the CBSE 083 syllabus. In the 2026-27 sample paper, Section A has 21 one-mark questions: 15 MCQs, four short ones without options and two assertion and reason. This page is a test of 40 original questions, chapter wise, covering Python, functions, exceptions, files, stack, networks, SQL and connectivity, each with the correct option and a reason. Modern Age Coders goes through your wrong answers live, personalised one to one, on your own timing. A priority demo lets you try a full class first.

## How many MCQs come in the Class 12 Computer Science paper?

The 2026-27 sample paper has 15 MCQs, all in Section A, beside four one-mark questions without options and two of assertion and reason: 21 marks in all.

- Section A, sample paper 2026-27 | Question numbers | Count
- MCQ, four options | 2 to 9, 11 to 13, 15 to 17, 19 | 15
- Write the output or answer, no options | 1, 10, 14, 18 | 4
- Assertion and reason | 20, 21 | 2
- One mark each, no internal choice |  | 21

- By unit | Count
- Programming | 12
- Database | 6
- Networks | 3

That is one year's sample. The board paper follows the same five sections, but nobody outside the board knows its mix of MCQs.

### Rules for this test

- 50 minutes for 40, pen and paper, no Python open.

- Write the option, not only its letter. The paper says the text of the correct answer should also be written.

- Mark a guess with a dot. A correct guess is still a topic to revise.

- Answer all. The sample paper's instructions mention no deduction for a wrong option.

### Why the wrong option looks right

- The setter's trick | How to see through it | Try it in
- The stop value included | Slices and range() end one early | 5, 6
- Print mistaken for return | No return means None | 10
- NULL counted as zero | Aggregates skip it | 28
- Columns and rows multiplied alike | Degree adds, cardinality multiplies | 25
- Half of a correct sentence | Read all four options to the end | 23, 24
- Two true statements | Put because between them | 34, 37

## Class 12 computer science MCQ chapter wise: Python and functions

Set 1 is the Class 11 Python that the board paper reuses. Set 2 is functions, scope and exception handling.

### Set 1. Python revised (1 to 7)

- What is displayed?
```
print("level 9".title().swapcase())
```
(a) LEVEL 9(b) Level 9(c) lEVEL 9(d) level 9
Answer (c) lEVEL 9. title() gives Level 9, and swapcase() turns each letter to the other case. The digit has no case.

- What is displayed?
```
t = (4, [5, 6])
t[1].append(7)
print(t)
```
(a) (4, [5, 6, 7])(b) (4, [5, 6], 7)(c) (4, [5, 6])(d) TypeError, since a tuple cannot change
Answer (a) (4, [5, 6, 7]). The tuple still holds the same two objects. One of them is a list, and a list may change.

- What is displayed?
```
print(2 ** 3 ** 0 + 10 % 4 * 2)
```
(a) 5(b) 6(c) 9(d) 3
Answer (b) 6. Powers go from the right: 3 ** 0 is 1, so 2 ** 1 is 2. Then 10 % 4 is 2, times 2 is 4, and 2 + 4 is 6.

- What is displayed?
```
d = {"a": 1}
d["b"] = d.get("c", 5)
d.pop("a")
print(d)
```
(a) {'a': 1, 'b': 5}(b) {'b': None}(c) {'c': 5}(d) {'b': 5}
Answer (d) {'b': 5}. get("c", 5) returns 5 and adds no key c. Then the key a is removed.

- What is displayed?
```
L = [1, 2, 3, 4, 5, 6]
print(L[-2:1:-2])
```
(a) [5, 3, 1](b) [5, 3](c) [2, 4](d) [6, 4]
Answer (b) [5, 3]. Index -2 is the 5. Stepping back by two gives indexes 4 and 2; index 1 is the stop and is not reached.

- Which output is not possible?
```
import random
N = ["Rut", "Kol", "Sur", "Mad"]
a = random.randint(0, 1)
b = random.randrange(2, 4)
for i in range(a, b):
    print(N[i], end="/")
```
(a) Kol/(b) Rut/Kol/(c) Kol/Sur/(d) Kol/Sur/Mad/
Answer (d) Kol/Sur/Mad/. b is 2 or 3, so i is at most 2 and Mad, at index 3, is never shown.

- What is displayed?
```
print(not 5 > 3 or 7 and 0)
```
(a) 0(b) True(c) 7(d) False
Answer (a) 0. not 5 > 3 is False. 7 and 0 gives 0. False or 0 gives the last value looked at, which is 0.

### Set 2. Functions and exceptions (8 to 12)

- What is displayed?
```
def f(a, b=2, c=3):
    return a + b * c

print(f(4, 1))
```
(a) 10(b) 18(c) 7(d) 6
Answer (c) 7. a is 4, b becomes 1 and c keeps 3, so 4 + 1 * 3 is 7.

- What is displayed?
```
x = 10
def g():
    global x
    x += 5
    return x

print(x, g(), x)
```
(a) 15 15 15(b) 10 15 15(c) 10 15 10(d) 10 10 15
Answer (b) 10 15 15. The three arguments are worked out from left to right: the first x is read before the call, the last one after it.

- What does the second print display?
```
def show(n):
    print(n * 2)

r = show(4)
print(r)
```
(a) 8(b) None(c) Nothing at all(d) NameError
Answer (b) None. The function prints 8 but has no return statement, so r is None.

- What is displayed?
```
try:
    print(int("7.5"))
except ZeroDivisionError:
    print("Z")
except ValueError:
    print("V")
finally:
    print("F")
```
(a) 7 and then F(b) V(c) Z and then F(d) V and then F
Answer (d) V and then F. int() cannot convert the text 7.5, so ValueError is raised and caught, and finally always runs.

- A function starts def park(car, hours=1):. Which call raises TypeError?(a) park()(b) park("KA01")(c) park("KA01", 4)(d) park(5, 2)
Answer (a) park(). car has no default, so a value must be given. The number 5 as a car is odd, but legal.

Two lines, then the options. For an output question cover the four options with your hand, write the value of each variable in two lines, and only then look. Students who read the options first tend to hunt for the one that feels familiar.

Less than four correct in either set? Go to [output questions with traces](/cbse-class-12-computer-science-output-questions) or to [the functions chapter](/cbse-class-12-computer-science-functions).

## File handling and stack MCQs for Class 12 CS

Set 3 has six questions: modes, reading, the file pointer, pickle, CSV and one stack trace.

- Which mode fails with FileNotFoundError if the file does not exist?(a) a+(b) w+(c) r+(d) a
Answer (c) r+. r+ reads and writes an existing file. The others create the file when it is missing.

- A file holds three lines: one, two, three. What is displayed?
```
f = open("nums.txt", "r")
f.readline()
print(len(f.readlines()))
f.close()
```
(a) 3(b) 2(c) 1(d) 0
Answer (b) 2. The first line has been read already, so readlines() returns only the two that remain.

- A file holds EXAM2027. What is displayed?
```
f = open("code.txt", "r")
f.seek(4)
print(f.read(2), f.tell())
f.close()
```
(a) M2 6(b) 20 4(c) 20 6(d) 20 5
Answer (c) 20 6. Position 4 is the first 2. Two characters are read, and the pointer moves to 6.

- All records of a binary file have been read and pickle.load() is called again. What happens?(a) It returns None(b) It starts again at the first record(c) It returns an empty list(d) EOFError is raised
Answer (d) EOFError is raised. This is why load() is placed in a loop inside try, with except EOFError.

- Each row given by csv.reader() is(a) a list of strings(b) a tuple of strings(c) one string with commas(d) a dictionary
Answer (a) a list of strings. Numbers arrive as strings too, so convert them before adding.

- What is displayed?
```
S = []
S.append(3)
S.append(8)
S.append(S.pop() + S.pop())
S.append(1)
S.pop()
print(S)
```
(a) [3, 8](b) [11](c) [11, 1](d) [3, 11]
Answer (b) [11]. Both values are popped before the sum 11 is pushed. The 1 is pushed and popped.

The chapter pages are [text files](/cbse-class-12-computer-science-file-handling), [CSV and binary files](/cbse-class-12-computer-science-csv-and-binary-files) and [stack](/cbse-class-12-computer-science-stack).

## Networking and SQL MCQs with answers

Set 4 is Unit 2, six questions. Set 5 is Unit 3, eight questions from keys to connectivity.

### Set 4. Networks (19 to 24)

- A device reads the destination of incoming data and forwards it to one port only. It is a(a) hub(b) repeater(c) modem(d) switch
Answer (d) switch. A hub would copy the data to every port.

- The files of a finished website have to be uploaded to the web server. The protocol made for this is(a) FTP(b) SMTP(c) POP3(d) VoIP
Answer (a) FTP. FTP moves files. SMTP and POP3 handle mail, VoIP handles calls.

- In https://fees.example.in/july.html, the domain name is(a) https(b) july.html(c) fees.example.in(d) fees.example.in/july.html
Answer (c) fees.example.in. The domain name names the site only. The whole text is the URL.

- The ATMs of one bank in eleven states are connected. The network is a(a) PAN(b) WAN(c) LAN(d) MAN
Answer (b) WAN. A MAN stops at a city. Eleven states need a WAN.

- Which statement about packet switching is true?(a) One path is reserved for the whole message(b) Packets must arrive in the order they were sent(c) The line stays idle when nobody is sending(d) Packets of one message may take different routes
Answer (d) Packets of one message may take different routes. The first and third describe circuit switching, and order is restored at the destination.

- Terminators are fitted in which topology, and why?(a) Star, to boost the signal(b) Bus, to absorb the signal at the ends of the cable(c) Tree, to join the switches(d) Star, to join two networks
Answer (b) Bus, to absorb the signal at the ends of the cable. Without them the signal would return along the backbone.

Revise from [computer networks for Class 12](/cbse-class-12-computer-science-computer-networks).

### Set 5. Database and connectivity (25 to 32)

- T1 has 3 columns and 4 rows. T2 has 5 columns and 6 rows. The degree and cardinality of their Cartesian product are(a) 15 and 10(b) 8 and 10(c) 8 and 24(d) 15 and 24
Answer (c) 8 and 24. Columns add, 3 + 5. Rows multiply, 4 x 6.

- Which command removes a table, its rows and its structure together?(a) DROP TABLE Stall;(b) DELETE FROM Stall;(c) ALTER TABLE Stall DROP;(d) UPDATE Stall SET NULL;
Answer (a) DROP TABLE Stall;. DELETE FROM empties the table but leaves the structure in place.

- The column Name holds Neha, Anita, Veda and Geet. Which rows satisfy Name LIKE '_e%a'?(a) Neha only(b) Neha, Veda and Geet(c) Neha and Veda(d) All four
Answer (c) Neha and Veda. One character, then e, then anything, ending in a. Geet ends in t, and Anita has n in second place.

- The column Price holds 10, NULL, 20 and 30. SELECT AVG(Price) gives(a) 15.0000(b) 20.0000(c) NULL(d) 60.0000
Answer (b) 20.0000. NULL is skipped: 60 is divided by 3 values, not 4.

- Which order of clauses is correct?(a) WHERE, HAVING, GROUP BY, ORDER BY(b) GROUP BY, WHERE, HAVING, ORDER BY(c) WHERE, GROUP BY, ORDER BY, HAVING(d) WHERE, GROUP BY, HAVING, ORDER BY
Answer (d) WHERE, GROUP BY, HAVING, ORDER BY. Choose rows, make groups, choose groups, then sort.

- A SELECT gave 3 rows. cur.fetchone() is called once and then cur.fetchall(). The second call returns(a) a list of 3 tuples(b) a list of 2 tuples(c) one tuple(d) None
Answer (b) a list of 2 tuples. fetchall() returns the rows not yet fetched.

- ORDERS.CustId is a foreign key to CUSTOMER.CustId. A value in ORDERS.CustId(a) must be found in CUSTOMER.CustId, unless it is NULL(b) must not repeat in ORDERS(c) must be the first column of ORDERS(d) must be NULL in CUSTOMER
Answer (a) must be found in CUSTOMER.CustId, unless it is NULL. A foreign key may repeat: one customer can place many orders.

- BOOK(Bid, Title) and LOAN(Lid, Bid, Day) are joined. How many columns appear with SELECT * in (i) an equi-join on Bid and (ii) a natural join?(a) 5 and 5(b) 4 and 5(c) 5 and 4(d) 4 and 4
Answer (c) 5 and 4. The equi-join keeps both copies of Bid. The natural join shows the common column once.

Revise from [SQL questions with results](/cbse-class-12-computer-science-sql-queries).

## Assertion reason questions, Class 12 Computer Science

Judge A alone, judge R alone, and only if both are true put the word because between them and listen.

- Option | In the words of the paper | When to choose it
- (a) | Both A and R are True and R is the correct explanation for A | "A because R" makes sense
- (b) | Both A and R are True and R is not the correct explanation for A | Two facts, no link
- (c) | A is True but R is False | R has one wrong word
- (d) | A is False but R is True | R often shows why A fails

### One pair, four ways

Keep A fixed: "A list can be changed after it is made." Now change R. "A list is mutable" gives (a). "A list is written in square brackets" gives (b). "A list is immutable" gives (c). Make A "A string can be changed after it is made" with R "Strings are immutable", and you have (d). Writing four such sets on your own topic teaches more than answering forty.

- Assertion (A): A tuple of two strings can be a dictionary key.Reason (R): A key must be an immutable object, and such a tuple is immutable.
Answer (a) Both A and R are True and R is the correct explanation for A. Because works between them: it can be a key because it is immutable.

- Assertion (A): The finally block runs even when no exception occurs.Reason (R): A try block may be followed by finally without any except.
Answer (b) Both A and R are True and R is not the correct explanation for A. Both are facts about finally, but the second does not cause the first.

- Assertion (A): To add a record at the end of a binary file, it is opened in wb mode.Reason (R): Opening a file in wb mode erases its old contents.
Answer (d) A is False but R is True. Adding needs ab. The reason is true, and shows why A is false.

- Assertion (A): readlines() returns a list of strings.Reason (R): readlines() removes the newline character from each line.
Answer (c) A is True but R is False. Each string keeps its newline, except perhaps the last.

- Assertion (A): Calling pop() on an empty list raises IndexError.Reason (R): A stack works on the principle last in, first out.
Answer (b) Both A and R are True and R is not the correct explanation for A. The order of removal is not why an empty list gives an error.

- Assertion (A): A switch causes less unneeded traffic than a hub.Reason (R): A switch sends data only to the port of the device it is meant for.
Answer (a) Both A and R are True and R is the correct explanation for A. The reason is exactly how the traffic is reduced.

- Assertion (A): A table can have several primary keys.Reason (R): A table can have several candidate keys.
Answer (d) A is False but R is True. One candidate is chosen as the primary key; the others become alternate keys.

- Assertion (A): SELECT * FROM A, B; gives the Cartesian product of A and B.Reason (R): It keeps only the rows whose common columns match.
Answer (c) A is True but R is False. With no condition every row of A is paired with every row of B. Matching needs a join condition.

## Class 12 CS MCQ online test: answer key and score

Count each set separately. The total tells you little, but the weakest set tells you what to study this week.

### Answer key

- No. | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
- 1 to 10 | c | a | b | d | b | d | a | c | b | b
- 11 to 20 | d | a | c | b | c | d | a | b | d | a
- 21 to 30 | c | b | d | b | c | a | c | b | d | b
- 31 to 40 | a | c | a | b | d | c | b | a | d | c

Read along a row: the third letter in the row 21 to 30 is the answer to question 23.

### By set

- Set | Out of | Revise if below | First thing to do
- 1. Python | 7 | 5 | Trace ten outputs on paper
- 2. Functions, exceptions | 5 | 4 | Write each function and call it twice
- 3. Files, stack | 6 | 4 | Try every mode on one small file
- 4. Networks | 6 | 5 | Say the job of nine devices aloud
- 5. Database | 8 | 6 | Type the queries, with a NULL in the table
- 6. Assertion, reason | 8 | 6 | Make four sets from one topic

The limits are our teaching guide, not a CBSE rule. Take the test again after ten days with the order of sets reversed.

### In class, the key is hidden
You explain why three options are wrong. If you can, the fourth needs no luck.

### In class, the number changes
Same code, new values. A remembered answer fails at once, an understood one does not.

### In class, it becomes two marks
An MCQ on scope turns into "define and give an example", since Section B asks for the same ideas.

Longer answers come next: [important questions by chapter](/cbse-class-12-computer-science-important-questions), and a full Section A under time in [our 2026-27 sample paper](/cbse-class-12-computer-science-sample-paper-2026-27).

## The courses behind this page

- [Computer Science 11 and 12](/courses/cbse-icse-computer-science-class-11-12-python-java-complete-course): Every chapter these questions are drawn from, on the CBSE track, with the practical side taught next to the theory.
- [Python for Teens](/courses/python-complete-masterclass-teens): For a student who guesses outputs: strings, lists, dictionaries, loops and functions built up through code you write.
- [MySQL for Teens](/courses/mysql-mastery-for-teens): NULL, grouping, joins and keys become plain once you have typed them many times. That is what this course does.

Families also look at [CBSE Informatics Practices Class 11 and 12](/courses/cbse-informatics-practices-ip-class-11-12-python-pandas-sql-complete-course), [CBSE Computational Thinking and AI for Classes 9 to 12](/courses/cbse-computational-thinking-and-ai-course-for-teens-classes-9-to-12-code-417-843), [Java Programming for Teens](/courses/java-programming-masterclass-for-teens), [Data Science for Teens](/courses/data-science-course-for-teens-python-data), [AI and ML for Teens](/courses/ai-ml-masterclass-teens), [Data Structures and Algorithms](/courses/data-structures-algorithms-masterclass-college), [Full-Stack Web for Teens](/courses/full-stack-web-development-teens-masterclass), [Hackathon Prep for Teens](/courses/hackathon-prep-for-teens-coding-ai-build-innovate-win-course), [Git and GitHub for Teens](/courses/git-github-version-control-course-for-teens), [JavaScript for Teens](/courses/javascript-course-for-teens-beginners-interactive-web), [Visual Machine Learning with Orange for Teens](/courses/orange-data-mining-visual-machine-learning-course-for-teens).

## Classes, demo and fees

Personalised one to one, live online, days and time chosen by the family. Monthly billing, no admission fee, stop at any month end. Fees are shown on the page in the visitor's own currency. Try it first: a priority demo (about 45 to 60 minutes, written skill report afterwards) at a slot you pick, or a free demo class.

## Class times outside India

- Where you live | Time difference | Usual class window, local time | Format

- Indiaevery Indian city | Indian time | Any time you choose | Personalised 1-on-1

- UAE and OmanDubai, Abu Dhabi, Sharjah, Muscat | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1

- Saudi Arabia, Qatar, Kuwait, BahrainRiyadh, Jeddah, Dammam, Doha, Kuwait City, Manama | 2 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1

- NepalKathmandu | 15 min ahead of India | 4:30 PM to 9:00 PM | Personalised 1-on-1

- Ethiopia and East AfricaAddis Ababa and East Africa Time | 2 h 30 min behind India | 4:30 PM to 9:00 PM | Personalised 1-on-1

- Singapore and MalaysiaSingapore, Kuala Lumpur | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1

## Frequently asked questions

**How many MCQs are there in the Class 12 Computer Science board exam?** In the CBSE sample paper for 2026-27, Section A has 21 one-mark questions, of which 15 are MCQs with four options, four have no options and two are assertion and reason. The board paper keeps the same section, though its exact mix is known only on the day.

**Where can I practise Class 12 computer science MCQs with answers?** On this page: 40 original questions in six sets, covering Python, functions, exceptions, files, stack, networks, SQL and assertion and reason. Each has its answer and a reason, and the outputs and queries were run before they were printed. The key is in one table at the end.

**Do I have to write the full answer in MCQs in CBSE Class 12 CS?** Yes. The general instructions of the 2026-27 sample paper say that in an MCQ the text of the correct answer should also be written. Write the letter and the text of the option, and for a code option copy it exactly, with its brackets and quotes.

**Is there negative marking in Class 12 Computer Science?** The sample paper and its marking scheme mention no negative marks. So attempt all 21 questions of Section A. If you have to guess, strike out the options you can prove wrong first, and put a small mark so that you return if time is left.

**How do I solve assertion reason questions in computer science?** Read the assertion and decide true or false. Do the same for the reason, without linking them. If both are true, join them with the word because. If the sentence makes sense, choose (a); if not, (b). One wrong word in the reason makes it (c).

**Which chapters have the most MCQs in Class 12 CS?** In Section A of the 2026-27 sample paper, 12 questions came from programming, six from databases and three from networks. That is close to the unit weights of 40, 20 and 10 marks, so prepare Python and SQL first and networks for quick, certain marks.

**How much time should I give to Section A?** About 30 minutes for 21 questions is comfortable, leaving the rest of the three hours for programs, SQL and the network case. Do the definition and SQL items first, then the outputs, which need writing. Keep a few minutes at the end to check spaces and brackets.

**Are MCQs enough to prepare for Class 12 Computer Science?** No. Section A is 21 of 70 marks, and the other sections ask you to write programs, queries and short explanations. Use MCQs to find weak ideas quickly, then write a program or query on each. Recognising an answer is easier than producing one.

**Are these MCQs from previous year papers?** No, they are original questions written for this page in the style of Section A. Nothing is copied from a board paper, the sample paper or a book. For official questions use the sample papers and question papers published by CBSE.

**Can you take my child through MCQs chapter by chapter?** Yes, one to one and at the time your family chooses. The teacher asks for the reason behind each option, so the weak chapter shows within a lesson. You can see a whole class first through the priority demo, or meet us in the free demo class.

Rated 4.9 across 547 Google reviews. Teaching since 2020, more than 10,000 students. Contact: connect@modernagecoders.com, +91 91233 66161 (call or WhatsApp).

## More pages in this series

**Practicals, project and viva:** [Class 12 CS viva questions](/cbse-class-12-computer-science-viva-questions), [Class 12 CS project with source code](/cbse-class-12-computer-science-project-python-mysql), [Class 12 CS project topics](/cbse-class-12-computer-science-project-topics).

**Exam, papers and marks:** [Class 12 CS sample paper practice](/cbse-class-12-computer-science-sample-paper-2026-27), [Class 12 CS exam date, pattern and marks](/cbse-class-12-computer-science-paper-pattern-and-marking-scheme), [Class 12 CS important questions](/cbse-class-12-computer-science-important-questions).

**Questions and practice:** [Class 12 CS output questions](/cbse-class-12-computer-science-output-questions), [Class 12 CS case study questions](/cbse-class-12-computer-science-case-study-questions), [Class 12 CS SQL questions](/cbse-class-12-computer-science-sql-queries).

**Chapter by chapter:** [Functions in Python Class 12](/cbse-class-12-computer-science-functions), [Exception handling Class 12](/cbse-class-12-computer-science-exception-handling), [Text file handling Class 12](/cbse-class-12-computer-science-file-handling), [CSV and binary files Class 12](/cbse-class-12-computer-science-csv-and-binary-files), [Stack Class 12 Computer Science](/cbse-class-12-computer-science-stack), [Computer networks Class 12](/cbse-class-12-computer-science-computer-networks), [Python MySQL connectivity Class 12](/cbse-class-12-computer-science-python-mysql-connectivity).

**Notes, revision and help:** [Class 12 CS syllabus 2026-27](/cbse-class-12-computer-science-syllabus-2026-27), [Class 12 CS notes](/cbse-class-12-computer-science-notes), [Class 12 CS revision plan](/cbse-class-12-computer-science-revision-plan), [Class 12 CS crash course](/cbse-class-12-computer-science-crash-course).

---

*Canonical: https://learn.modernagecoders.com/cbse-class-12-computer-science-mcq-test*
