CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →
CBSE Class 12 Computer Science · MCQ practice

CBSE Class 12 Computer Science Multiple Choice Questions, with Answers

10 practice questions for CBSE Class 12 Computer Science. Every question whose answer is the output of a program was run before publishing, so the answer is what the code really prints — not what it looks like it should.

1. What does the following print?
s = [1, 2, 3]
s.append([4, 5])
print(len(s))
  1. 3
  2. 4
  3. 5
  4. Error
Show the answer
Answer: 4
append() adds the whole list as ONE element, so the length becomes 4. extend() would have made it 5.
2. What is the output?
t = (1, 2, 3)
print(t[-1] + t[0])
  1. 2
  2. 3
  3. 4
  4. Error
Show the answer
Answer: 4
t[-1] is the last element, 3, and t[0] is 1.
3. What does this print?
d = {'a': 1, 'b': 2}
print(d.get('c', 0) + d['a'])
  1. 0
  2. 1
  3. 2
  4. KeyError
Show the answer
Answer: 1
get() returns the default 0 for a missing key instead of raising KeyError.
4. What is printed?
def f(x, lst=[]):
    lst.append(x)
    return lst
print(f(1))
print(f(2))
  1. [1] then [2]
  2. [1] then [1, 2]
  3. [1, 2] then [1, 2]
  4. Error
Show the answer
Answer: [1] then [1, 2]
A mutable default argument is created once and reused on every call. This is a classic trap: use None as the default instead.
5. What does this print?
st = []
for i in range(1, 4):
    st.append(i * i)
print(st.pop(), st)
  1. 9 [1, 4]
  2. 1 [4, 9]
  3. 9 [1, 4, 9]
  4. Error
Show the answer
Answer: 9 [1, 4]
pop() removes and returns the top of the stack, which is the last item.
6. What is the output?
print('Kwickprep'[2:5])
  1. ick
  2. ickp
  3. wic
  4. ckp
Show the answer
Answer: ick
Slicing starts at index 2 and stops before index 5.
7. Which SQL clause filters groups rather than rows?
  1. WHERE
  2. HAVING
  3. ORDER BY
  4. GROUP BY
Show the answer
Answer: HAVING
WHERE filters rows before grouping. HAVING filters the groups afterwards, so it can use aggregate functions.
8. A primary key can be NULL.
  1. True
  2. False
Show the answer
Answer: False
A primary key must uniquely identify every row, so it can be neither NULL nor duplicated.
9. Which file mode erases the existing contents?
  1. r
  2. a
  3. w
  4. r+
Show the answer
Answer: w
w truncates the file to zero length before writing. a appends instead.
10. In a stack, popping from an empty stack is called
  1. overflow
  2. underflow
  3. traversal
  4. overwrite
Show the answer
Answer: underflow
Underflow is removing from empty; overflow is adding to a full fixed-size stack.

Want the full set?

More questions, the practical file format and the topics examiners come back to — sent on WhatsApp.

Get it on WhatsApp Book a free demo class

Written by Kajal Ma'am (MCA), teaching computer subjects since 2004. Every code answer on this page was checked by running it.

Please read: these are practice questions written by Kwickprep to help you revise. They are not past examination papers and not a CBSE publication. Questions asked in your school’s viva or examination may differ, and the syllabus can change between sessions — the board’s own document at cbseacademic.nic.in is always the final word. Tell us if you spot a mistake and we will correct it.

{ }

Frequently asked questions

How many programs are needed in the CBSE Class 12 CS practical file?+
As per CBSE, the report file should contain a minimum of 15 Python programs and 5 sets of SQL queries. The practical is 30 marks (lab test 12, report file 7, project 8, viva 3).
Are these programs part of the CBSE syllabus?+
Yes, these are standard CBSE Class 12 Computer Science (083) practical concepts: stacks, file handling, recursion, searching, dictionaries and Python-MySQL connectivity. Every program here has been run and its output verified.
Can I get the full practical file and viva questions?+
Yes, request the full pack (15+ programs, the CBSE practical-file format and likely viva questions) on WhatsApp, free. Kajal Ma'am's team can also guide you through your own file.

Want to ace your boards?

See a real class before you decide. No pressure, no payment.

Book Free Demo on WhatsApp

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →