On this page
Class 12 computer science assumes you still remember Class 11 Python. Many students do not, and the first section of the board paper is full of one-mark questions that test exactly that: what does this line print, and why? This post lists what the syllabus covers, works through the kinds of snippets that get asked, with outputs checked by running them, and gives a routine for the weeks before the exam.
What Python does the CBSE Class 12 syllabus cover?
The CBSE Computer Science curriculum for Class XII (2026-27) gives Unit 1, Computational Thinking and Programming 2, 40 of the 70 theory marks. It begins with "Revision of Python topics covered in Class XI", then functions (built-in, module and user-defined; arguments and parameters; default and positional parameters; returning values; flow of execution; global and local scope), exception handling with try, except and finally, file handling and the stack. This post covers the revision, functions and exceptions. For the rest, see our guides to file handling in Python and stacks in Python.
The CBSE sample question paper for 2026-27 shows the style. Its Section A asks for outputs of list insertion, string splitting, a tuple joined to a list, floor division and a mixed expression with powers, and asks what happens when a function changes a global variable without declaring it.
Which operator rules appear in output questions?
Run these yourself; each output below is what Python 3 prints.
print(2 ** 3 ** 2) # 512
print(17 // 5, 17 % 5, 17 / 5) # 3 2 3.4
print(type(5 // 2).__name__) # int`` groups from the right, so `2 3 2` is `2 9`, which is 512, not `8 ** 2`.
`//` is floor division and `%` is the remainder. With two integers, `//` gives an int; `/` always gives a float.
What string, list and tuple behaviour is tested?
s = "COMPUTER"
print(s[1:4], s[::-1], s[-3:]) # OMP RETUPMOC TER
print("a,b,,c".split(",")) # ['a', 'b', '', 'c']
L = [3, 6, 9]
L.insert(1, 4)
print(L) # [3, 4, 6, 9]A slice `s[a:b]` stops before index b. A step of −1 reverses.
`split` keeps an empty string between two separators that are next to each other.
`insert(i, x)` puts x at index i and shifts the rest right.
Tuples are immutable. `t[0] = 5` on a tuple raises a TypeError, and so does `(1, 2) + [3]`, because a tuple can only be joined to another tuple. Lists are mutable, and two names can share one list: after `y = x` and `y.append(4)`, x has changed too.
For dictionaries, `in` checks keys, not values. With `d = {"Pen": 12, "Ink": 20}`, `"Pen" in d` is True and `12 in d` is False. `d.get("Ruler", 0)` returns 0 instead of raising an error.
How do functions, parameters and scope work?
A function can return several values at once; Python packs them into a tuple.
def stats(nums):
return min(nums), max(nums), sum(nums) / len(nums)
lo, hi, avg = stats([4, 8, 6])
print(lo, hi, avg) # 4 8 6.0Default parameters must come after the others. `def greet(name, msg="Hello")` is valid; putting a default parameter before a non-default one is a SyntaxError. The Python tutorial also notes that default values are evaluated once, when the function is defined, which matters if the default is a list.
Scope is where most marks go. If a function assigns to a name, that name is local to the function, unless you declare it `global`:
count = 10
def add_one():
global count
count = count + 1
add_one()
print(count) # 11Remove the `global` line and the call fails. The Python FAQ explains that when you make an assignment to a variable in a scope, it "becomes local to that scope", so reading it before the assignment raises an UnboundLocalError.
How does exception handling with try, except and finally work?
def safe_divide(a, b):
try:
result = a / b
except ZeroDivisionError:
result = None
print("Cannot divide by zero")
finally:
print("Done")
return result`safe_divide(10, 2)` prints Done and returns 5.0. `safe_divide(1, 0)` prints the message, then Done, and returns None. The Python tutorial on errors states that the finally clause "runs whether or not the try statement produces an exception". NCERT gives this topic its own chapter, Exception Handling in Python.
What mistakes cost marks?
Reading `` from the left.** It groups from the right.
Forgetting that `/` gives a float, so outputs show 5.0, not 5.
Slicing one place too far. The end index is excluded.
Missing UnboundLocalError in a function that changes a global name.
Writing outputs without brackets and quotes. A list prints with square brackets and string items in quotes.
A practice routine for the Python basics
Every day for two weeks: Write five one-line snippets on paper, predict the outputs, then run them. Keep a list of every prediction you got wrong and why.
Twice a week: Write one function from the suggested practical list in the curriculum without looking anything up, then test it.
Weekly: Solve Section A of a sample paper in 25 minutes, then run each output question to check.
Before the practical exam: Read our notes on the board practical exam and viva.
When the gap is the idea rather than the syntax, such as what scope means, the Fermi Concept Library has every concept in computing with its own lesson, so you can fix the idea before you go back to predicting outputs.
Open a Python shell today and predict, then run, the five snippets in this post.



