Board question types: output, errors, assertion-reason

Part of the free LogicWiz Python course, Pack A: CBSE Class 12 Board Pack. The examples and practice run in the app.

A big part of the board paper is reading code, not writing it: "What will be the output?", "Rewrite after removing the errors", "Assertion and Reason". These are the cheapest marks in the paper, if you trace instead of guess.

You'll learn to

  • Trace tricky outputs: precedence, slicing, split, global, dict.get, except order
  • Find every possible output of code that uses random.randint
  • Rewrite code with its errors removed, board style
  • Answer assertion-reason questions with the 4 standard options

Learn

Trace, don't guess

For any "what is the output" question:

  1. Make a small trace table: one column per variable.
  2. Go line by line. Update the table only when a line assigns.
  3. Write the output exactly: end= decides what follows each print, a list prints with brackets and quotes, / always gives a float (9.0).
  4. If a line would crash, the answer is the error, for example TypeError.

Precedence and slicing, the sample-paper favourites

print(20 - 2 ** 3 ** 2 // 64 + 81 / 9)
s = "Board Exams"
print(s[-2::-3])
print(s[1:8:2], s[::-1][:3])
print("Mummy commits".split("m"))

** is evaluated right to left: 2 ** 3 ** 2 is 2 ** 9 = 512, not 8 ** 2. Then 512 // 64 = 8, 81 / 9 = 9.0, so the answer is 21.0. split makes an empty string '' wherever two separators are next to each other.

Possible outputs with randint

import random
colours = ["RED", "BLUE", "GREEN", "PINK", "GOLD"]
start = random.randint(1, 2)
end = random.randint(2, 3)
for i in range(start, end + 1):
    print(colours[i], end="#")
print()

Run it a few times. randint(a, b) includes both a and b. start is 1 or 2 and end is 2 or 3, so the only possible outputs are BLUE#GREEN#, BLUE#GREEN#PINK#, GREEN# and GREEN#PINK#. RED and GOLD can never print.

Random-output method: write the smallest and largest value of every random variable, list every combination, then strike out each option that needs a value outside those ranges. Also note randrange(a, b) excludes b, unlike randint.

When the answer is an error

for k in range(3, 20, 7):
    print(k + "*")

k is an int and "*" is a str, so + raises TypeError on the very first pass. Nothing is printed. In the exam, write the error name as the output.

Error finding: rewrite and underline

The question says: "Rewrite the code after removing all the errors. Underline each correction." Look for:

  • misspelt keywords: define, Def, retrun, Print, If
  • a missing : after def, if, for, while, else
  • a missing comma or bracket in print(...)
  • = where == is needed, =+ where += is needed
  • off-by-one slices like s[1:-2] when s[1:-1] is meant

On paper you underline; here you fix the code and the tests check it.

Assertion (A) and Reason (R)

Every A-R question has the same four options:

  • (a) Both A and R are true, and R is the correct explanation of A.
  • (b) Both A and R are true, but R is not the correct explanation of A.
  • (c) A is true, but R is false.
  • (d) A is false, but R is true.

Method: judge A on its own, then R on its own. Only if both are true, ask: "A because R?" If that sentence makes sense, choose (a); otherwise (b).

In the 2025-26 sample paper, 1-mark output questions covered ** precedence, negative slicing, split(), global, dict.get() with a default, except-clause order and randint ranges. 2- and 3-mark questions traced loops over strings, lists and dicts. Practise all of these below.

In one line

Trace with a table; ** goes right to left; randint includes both ends; except clauses are tried top to bottom; in A-R, judge A and R separately, then ask "A because R?".