★★★★★
"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
CBSE Class 12 · Computer Science, code 083 · Find the output
These class 12 computer science output questions are short programs that look harmless. Each one hides a single rule: a list shared by two names, a function that returns nothing, a random range that stops early. Write your answer on paper, spaces and brackets included, then open ours. Where a guess would be tempting, the answer shows the trace.
Live one to one · 40 original items · every answer checked by running the code · any day, any hour you like
Start here
Tracing is a Class 11 skill that the Class 12 paper keeps testing. The first course rebuilds it inside the syllabus, the second outside it, and the third covers the output questions written in SQL.

Class 11 and 12 / Syllabus
Sets aside time for tracing loops and counting iterations in Class 11, then functions, exceptions and files in Class 12.
Open the course →
Python / Reading and writing
Truth values, short-circuit logic, exceptions and collections, met first in small programs the student writes.
Open the course →
SQL / Predict the rows
The sample paper can ask for the output of four queries. This course teaches you to see the rows before you run them.
Open the course →Ans. The short version
Class 12 computer science output questions ask you to write exactly what a short Python program prints. In the CBSE 083 sample paper for 2026-27 they carry nine marks in Section A and two in Question 26, with two more for finding errors. The usual traps are scope, default and mutable arguments, None from a function, slicing steps, exceptions and the limits of randint() and randrange(). This page has 40 original items with answers. Modern Age Coders practises them live, personalised one to one at your own timing, and a priority demo lets you try a class first.
Q1. Where are they, and how do I solve one?
In the official 2026-27 sample paper we counted nine one-mark Python output questions, one two-mark output and one two-mark error correction: 13 of the 70 marks with no choice, and up to six more if you pick the output option in Questions 25 and 32.
| Question in the SQP | What it tests | Marks |
|---|---|---|
| 1, 2, 7, 18 | list, string and dictionary behaviour | 4 |
| 5 | what happens when the code runs | 1 |
| 6 | possible output with random | 1 |
| 10 | an expression with several operators | 1 |
| 14 | what a program writes to a file | 1 |
| 16 | scope of a variable | 1 |
| 26 | a loop over a string | 2 |
| 23 | find and correct the errors | 2 |
| 25 B, 32 B | Python output, SQL output (if chosen) | 2 + 4 |
The actual 2027 paper may spread them differently. The skill is the same.
Nothing in a function runs until it is called. Find the first line that does run.
Add a row each time a loop turns or a call is made.
Note its end and sep. They decide the spaces and the lines.
7 or 7.0, '7' or 7, a list or a tuple: the brackets and quotes are part of the answer.
The last value of range(), the empty case, the line after an exception.
word = "Udaipur"
code = ""
for i in range(len(word)):
if word[i] in "aeiou":
code += str(i)
elif i % 2 == 0:
code = word[i].upper() + code
else:
code += word[i]
print(code)RPUd235
| i | word[i] | Rule that applies | code after |
|---|---|---|---|
| 0 | U | capital, not in "aeiou"; i even, to the front | U |
| 1 | d | i odd, to the end | Ud |
| 2 | a | vowel, adds 2 | Ud2 |
| 3 | i | vowel, adds 3 | Ud23 |
| 4 | p | i even, to the front | PUd23 |
| 5 | u | vowel, adds 5 | PUd235 |
| 6 | r | i even, to the front | RPUd235 |
Q2. Operators, strings, lists, dictionaries
A one-mark output tests one rule. Fourteen rules follow, seven on operators and strings and seven on lists, tuples and dictionaries.
print(2 ** 3 ** 2 // 10 % 7, -17 // 5, -17 % 5)
print(not 4 > 3 or 5 and 0, bool("False"))not 4 > 3 is False; 5 and 0 gives 0; False or 0 gives 0, not False. Any non-empty string is True.t = "Monsoon 2027" print(t[2:9:2], t[-4:], t[::-3])
s = "cricket"
print(s.replace("c", "k", 1), s.find("k"), s.count("c"))x = "red-green--blue"
p = x.split("-")
print(p, len(p))print("Lab" * 2 + "5" * 3, "10" > "9")m = " pYthon Lab " print(m.strip().capitalize(), len(m))
a = [1, 2, 3] b = a c = a[:] a.append(4) b[0] = 9 print(a, c)
L = [5, 3, 8] print(L.sort(), L)
nums = [2, 4, 6, 7, 8]
for x in nums:
if x % 2 == 0:
nums.remove(x)
print(nums)p = [1] p.append([2, 3]) p.extend([4, 5]) print(p, len(p))
t = (4, [5, 6]) t[1].append(7) print(t, len(t))
t[0] = 1 would be a TypeError.d = {}
for w in ["ab", "c", "de", "c"]:
d[len(w)] = d.get(len(w), "") + w
print(d)d = {3: "c", 1: "a"}
d[2] = "b"
d[3] = "z"
print(list(d), d.pop(1), len(d))More one-mark practice, with options and assertion-reason items, is in the Class 12 CS MCQ test.
Q3. Functions
In a function question, write the parameters as fresh variables and ask two things: is the value changed in place or replaced, and what is returned?
def park(hours, rate=20, fixed=10):
return fixed + hours * rate
print(park(2), park(2, 5), park(2, 5, 0))fuel = 50
def drive(km):
fuel = 40
fuel -= km
return fuel
def refill(n):
global fuel
fuel += n
return fuel
print(drive(15), fuel, refill(5), fuel)score = 12
def bonus():
print(score)
score = 20
bonus()def edit(marks, n):
marks.append(n)
n = n * 10
marks = [0]
marks.append(n)
return len(marks)
m = [7]
k = 5
print(edit(m, k), m, k)marks = [0] the name points to a new list, so the second append does not. An integer never changes outside.def shout(word):
print(word.upper())
print(shout("go"), len("go"))def log(item, box=[]):
box.append(item)
return box
print(log("pen"))
print(log("ink", []))
print(log("nib"))def stage(x):
print("in", x)
return x + 2
print(stage(stage(1)) * 2)def turn(a, b):
return b, a - b
x, y = turn(9, 4)
x, y = turn(x, y)
print(x, y)a, b = 3, 8
def swap(b, a):
a, b = b, a + b
print(a, b)
swap(a, b)
print(a, b)If items 16 to 18 went wrong, the notes on parameters and scope are in functions in Python for Class 12.
Q4. Loops, exceptions, stack and files
These programs jump. Trace the order of lines first and the values second.
x, total = 5, 0
while x > 1:
for k in range(1, x, 2):
total += k
print(x, total, end=" | ")
x -= 2
print(x)| x | k takes | total | Printed |
|---|---|---|---|
| 5 | 1, 3 | 4 | 5 4 | |
| 3 | 1 | 5 | 3 5 | |
| 1 | loop ends | 5 | 1 |
route = "NH44-Km9"
new = ""
for ch in route:
if ch.isupper():
new += ch.lower()
elif ch.isdigit():
new += str(int(ch) + 1)
elif ch.isalpha():
new = ch.upper() + new
else:
new += "/"
print(new)| ch | Branch | new |
|---|---|---|
| N, H | upper | nh |
| 4, 4 | digit | nh55 |
| - | else | nh55/ |
| K | upper | nh55/k |
| m | alpha | Mnh55/k |
| 9 | digit | Mnh55/k10 |
stock = {"A": [3, 0], "B": [1, 4], "C": [0, 0]}
for k in stock:
if sum(stock[k]) == 0:
continue
print(k * len(stock[k]), max(stock[k]), sep=":")st = []
for x in [5, 12, 7, 20, 9]:
if x > 10 and st:
st[-1] += x
else:
st.append(x)
print(st.pop(), st)for v in [4, "2", 0, 8]:
try:
print(8 // v, end=" ")
except ZeroDivisionError:
print("zero", end=" ")
except TypeError:
print("type", end=" ")
finally:
print("*", end=" ")def read(text):
try:
return int(text)
except ValueError:
return -1
finally:
print("read", text)
print(read("15") + read("1.5"))try:
print("A")
L = [1, 2]
print(L[2])
print("B")
except IndexError:
print("C")
print("D")with open("tag.txt", "w+") as f:
f.write("Kaziranga")
f.seek(4)
print(f.read(3), f.tell())
f.seek(0)
print(f.read()[::-2])For more like these, read exception handling, text files with seek and tell and the stack.
Q5. The random module
A possible-output question is solved by listing all the values each random call can give, and striking out every option that needs another value.
| Call | Can give | Cannot give |
|---|---|---|
random.randint(2, 5) | 2, 3, 4, 5 | 6 |
random.randrange(2, 5) | 2, 3, 4 | 5 |
random.randrange(5) | 0, 1, 2, 3, 4 | 5 |
random.randrange(1, 8, 3) | 1, 4, 7 | 8, or anything between |
random.random() | 0 up to just below 1 | 1 |
import random
bay = ["Kochi", "Goa", "Puri", "Diu", "Vizag"]
size = random.randint(1, 3)
for i in range(size):
print(bay[i], end="*")(a) Kochi*Goa*Puri*Diu*
(b) Goa*Puri*
(c) Kochi*Goa*
(d) Kochi*Vizag*
import random w = "JASMINE" a = random.randrange(1, 4) b = random.randint(4, 5) print(w[a:b])
(a) JASM
(b) SMI
(c) ASMIN
(d) MINE
| a | b = 4 | b = 5 |
|---|---|---|
| 1 | ASM | ASMI |
| 2 | SM | SMI |
| 3 | M | MI |
import random x = 10 * random.randint(1, 3) + random.randrange(5, 8) print(x)
(a) 18
(b) 27
(c) 38
(d) 30
import random
size = random.randint(2, 4)
for k in range(size, 0, -1):
print(k * 2, end="<")(a) 2<4<6<
(b) 8<6<4<
(c) 6<4<2<
(d) 4<2<0<
import random
size = int(random.random() * 4) + 3
print("#" * size)import random
p = ["Ram", "Sia", "Tej", "Uma"]
for i in range(3):
print(p[random.randrange(0, 2) + i], end="-")(a) Ram-Sia-Tej-
(b) Sia-Sia-Uma-
(c) Sia-Tej-Tej-
(d) Ram-Uma-Tej-
Q6. Find the error
Read the program three times: once for punctuation, once for names and case, once for sense. The sample paper gives half a mark for each of four corrections, and asks you to underline them.
def result(marks=40, name):
if marks => 75
print(name, "has passed")
else:
print(name, 75 - marks "short")
result(62, "Ira")def result(name, marks=40):
if marks >= 75:
print(name, "has passed")
else:
print(name, 75 - marks, "short")
result("Ira", 62)Ira 13 short
def tally(words)
d = {}
for w in words:
if w in d:
d[w] =+ 1
else:
d[w] = 1
return D
print(tally["sun", "fog", "sun"])def tally(words):
d = {}
for w in words:
if w in d:
d[w] += 1
else:
d[w] = 1
return d
print(tally(["sun", "fog", "sun"])){'sun': 2, 'fog': 1}num = input("Number: ")
rev = 0
while num > 0:
digit = num // 10
rev = rev * 10 + digit
num = num % 10
print("Reverse is" + rev)num = int(input("Number: "))
rev = 0
while num > 0:
digit = num % 10
rev = rev * 10 + digit
num = num // 10
print("Reverse is", rev)Number: 472 Reverse is 274
| You lost marks on | Revise |
|---|---|
| 1 to 7 | operator order, slicing, what a string method returns |
| 8 to 14 | which methods change a list and which return a new one |
| 15 to 23 | scope, default values, None |
| 24 to 31 | the order in which lines run |
| 32 to 37 | the end points of the random calls |
| 38 to 40 | reading slowly |
In a class the student talks through the table row by row. The teacher hears the exact line where the idea slips.
After each item one thing is altered, a step, a default, an indent, and you predict again. That is how a rule is tested properly.
Short timed sets from mixed topics, written by hand, so that speed arrives without losing the brackets.
When forty items feel comfortable, sit a full 70-mark practice paper. For longer programs to trace, use 20 Python programs for CBSE Class 12.
One to one, at your own timing
A wrong output shows that something slipped. Only a teacher beside you can see where. So this practice is personalised one to one, on your days and at your time. Take a priority demo to see it work, one full live class whose fee is set against your first month if you enrol, or a free demo class if you want only a taste. The fee is monthly, admission costs nothing, and you can leave at any month end.
Before you enrol · Try a class
a full live class of about 45 to 60 minutes
The classes · Choose your own timing
₹4,999
per month, 4 private classes, fully flexible timingtwo private classes a week, at a time set with you
Output practice works in small, regular doses, so it is usually a part of each class and not the whole of it. The rest of the hour goes to writing programs, where more of the marks are. The monthly fee is on this page in your currency.
Studying outside India?
From Muscat to Kathmandu, CBSE students trace the same Python. Say which evenings are free and the sessions sit there.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India every Indian city | Indian time | Any time you choose | Personalised 1-on-1 |
| UAE and Oman Dubai, 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, Bahrain Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama | 2 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Nepal Kathmandu | 15 min ahead of India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Ethiopia and East Africa Addis Ababa and East Africa Time | 2 h 30 min behind India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore and Malaysia Singapore, Kuala Lumpur | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
Keep paper and a pen at the desk. The editor stays closed until you have written an answer, in class as in the exam hall.
What families say
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
Every page in the CBSE Class 12 Computer Science series, grouped by what you need.
CBSE Class 12 Informatics Practices (065): Class 12 IP practical file Class 12 IP project with source code Class 12 IP sample paper practice Class 12 IP important questions
CBSE Class 12 Information Technology (802): IT 802 practical and project file IT 802 Java notes and programs IT 802 notes
CBSE Class 11 CS, IP and AI: Class 11 CS practical file Class 11 IP practical file CS or IP in Class 11
ISC Computer Science (868): ISC Class 12 CS syllabus 2027 ISC Class 12 CS practice paper ISC Class 12 practical questions solved ISC Boolean algebra and K-maps
Program lists with output: Class 12 CS practical file 20 Python programs for Class 12 Menu-driven programs in Python
Questions about output questions
CBSE fixes no number. By our count of the 2026-27 sample paper, Python output questions take nine marks in Section A and two in Question 26, and Question 23 gives two for correcting errors. Choosing the output options in Questions 25 and 32 would add six more.
Find the first line that runs, make one column per variable, and write a row for each turn of the loop. Note the end and sep of every print. Most slips come from skipping the table to save time. With practice a two-mark trace takes three or four minutes.
Write the full list of values each random call can give, remembering that randint() includes both ends and randrange() leaves out the second. Work out the output for each combination, or for the extremes if there are many, and strike out the options that cannot occur.
randint(a, b) can return any whole number from a to b, including b. randrange(a, b) stops before b, and it accepts a step, so randrange(1, 8, 3) gives 1, 4 or 7. random() returns a decimal from 0 up to, but not including, 1.
Because it has no return statement and its call is inside print(). The function does its own printing, then hands back None, and the outer print shows it. Either call the function without print(), or return the value instead of printing it.
Write "Error" with its name if you know it, and the line and reason in a few words, such as "UnboundLocalError: score is local and used before it has a value". If some lines print before the failing line, write that output as well.
Yes, they show that you know the type and the separator. A list needs its square brackets and quotes round its strings, a tuple its round ones, and print() puts a space between items unless sep says otherwise. True and False begin with capitals.
Missing colons and brackets, wrong case in a keyword or a name, = where == is meant, a wrong operator, a missing conversion, wrong limits in range(), and one or two logical errors where the program runs but gives the wrong result. Underline every correction you make.
No. Recursion is not in the 083 Class 12 syllabus for 2026-27, and neither are queues or linked lists. Output questions come from the Class 11 topics in revision, functions and scope, exceptions, files and the stack.
Yes. In the 2026-27 sample paper, part B of Question 32 gives four queries and asks for their output, one mark each. It is an internal choice: part A asks you to write the queries. This page is about Python; SQL outputs have a page of their own.
Yes, live and personalised one to one, at days and times you choose. You can try a priority demo first: a full class of about 45 to 60 minutes, a written skill report afterwards, and the fee adjusted against the first month if you enrol. A free demo class is also open.
Start
For the free demo class, pick any five items from this page that you were unsure of. You trace, the teacher listens, and the rule you were missing is named.
A priority demo gives you a full class at your chosen slot: a mixed set, one error question, one random question and a written skill report that lists the kinds of mistake you make. Its fee is adjusted against the first month when you enrol.
Ready for queries? Class 12 SQL questions with outputs come next.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Every class is live video. The form requests a callback and reserves nothing.
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