★★★★★
"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 083 · Functions chapter 2026-27
Functions are the first new Python topic of Class 12, and the other chapters lean on it: file, stack and connectivity answers are nearly all written as functions. These notes take the 083 syllabus line apart one phrase at a time. You get what each phrase means, a program that shows it, and the mistake that costs the mark, then six programs marked the way an examiner marks and 18 questions to try with the answers closed.
Live one to one · every output below was run · your answers marked line by line · at hours you set
Start here
One course covers the whole 083 syllabus. The other two build the Python fluency and the database half around it.

083 / Both years
The CBSE track moves from Class 11 lists and strings into functions, exceptions, files, the stack and SQL, and you can join in any month.
Open the course →
Python / Write more
For a student who follows every def on the board but cannot start one alone: many small programs, each one written and not copied.
Open the course →
SQL / Next unit
The database unit is another 20 marks, and its Python programs are functions with a query inside.
Open the course →Ans. The short version
Functions in class 12 computer science (CBSE 083, 2026-27) means built-in functions, functions defined in a module and user defined functions: how to define and call them, positional and default parameters, return values, flow of execution, and global and local scope. Positional arguments match by order; a default is used only when its argument is left out; a name assigned inside a function is local unless declared global. Modern Age Coders teaches this chapter live, personalised one to one, at your own days and timing, and a priority demo lets you try one full class before you enrol.
Q1. What does the syllabus ask for?
A function is a named block of statements that runs only when it is called. The 083 syllabus lists types of function, creating a user defined function, arguments and parameters, positional and default parameters, returning values, flow of execution, and scope.
| Type of function | Where it comes from | What you do before using it | Example |
|---|---|---|---|
| Built-in | Already part of Python | Nothing, just call it | len(name), max(marks) |
| Defined in a module | A module such as math or random | Import the module | math.ceil(4.2), random.randint(1, 6) |
| User defined | You write it with def | Define it above the call | parcel_charge(3) |
def parcel_charge(weight, rate=40):
"""Return the charge for one parcel."""
charge = weight * rate
return charge
bill = parcel_charge(3)
print("Charge:", bill)Output
Charge: 120
def line. It must end with a colon.weight and rate, the names that receive values.charge back and ends the function.parcel_charge(3). No call, no output.weight.CBSE gives no separate marks for this chapter: it sits inside the 40 marks of Unit 1. In the 2026-27 sample paper, though, functions appear as a 1-mark scope question, a 2-mark choice on global and local variables, a 2-mark function to write and a 3-mark function to write, before you count the file and stack answers.
Q2. Which value lands in which parameter?
Positional arguments fill parameters from left to right. A default parameter keeps its own value when no argument reaches it. Most lost marks come from a call that skips a parameter in the middle.
Every row below is a call to the same function. Cover the right-hand columns and decide for yourself.
def tour(seats, city="Mysuru", rate=250):
return city + " " + str(seats * rate)| Call | seats | city | rate | Result |
|---|---|---|---|---|
tour(4) | 4 | Mysuru | 250 | 'Mysuru 1000' |
tour(4, "Ooty") | 4 | Ooty | 250 | 'Ooty 1000' |
tour(4, "Ooty", 300) | 4 | Ooty | 300 | 'Ooty 1200' |
tour(4, 300) | 4 | 300 | 250 | TypeError: 300 went to city, and a number cannot be joined to a string |
tour() | none | Mysuru | 250 | TypeError: seats is required |
tour(4, "Ooty", 300, 1) | TypeError: four arguments for three parameters | |||
tour(rate=300, seats=2) | 2 | Mysuru | 300 | 'Mysuru 600' (keyword call) |
tour(city="Ooty", 4) | SyntaxError: a positional argument cannot follow a keyword one |
In the header, once one parameter has a default, all those after it must have one too. def tour(seats=1, city) is a SyntaxError.
Python does not read the names of your variables. The first argument goes to the first parameter, whatever it is called.
An argument that is passed always wins over the default.
Too few for the required parameters, or too many in all, and the body never starts.
Are keyword arguments in the syllabus? The 2026-27 line for 083 names positional and default parameters only. Keyword arguments, where the call itself says rate=300, are not listed. You already use them in print(x, end=" ") and you may meet them in a book, so recognise one, but put your practice time into the other two.
def add_name(names):
names.append("Ira")
def new_list(names):
names = ["Zoya"]
team = ["Om", "Neel"]
add_name(team)
print(team)
new_list(team)
print(team)Output
['Om', 'Neel', 'Ira'] ['Om', 'Neel', 'Ira']
append() works on the list itself, so team grows. The second function only points its own local name at a new list.
Q3. In what order do the lines run?
Python reads the file from the top, remembers each def without running its body, and jumps into the body only at a call. When the function ends, control comes back to the exact place it left.
def add_gst(price): # 1
total = price + price * 18 / 100 # 2
return total # 3
def show_bill(item, price): # 5
print("Item:", item) # 6
amount = add_gst(price) # 7
print("Pay:", amount) # 8
show_bill("Kettle", 1000) # 10
print("Thank you") # 11Output
Item: Kettle Pay: 1180.0 Thank you
Flow: 1, 5, 10, 5, 6, 7, 1, 2, 3, 7, 8, 11. Line 7 appears twice: once to make the call, once to store what came back. The answer is 1180.0, a float, since / always gives a float.
def rainfall(days):
"""Return total, highest and dry days."""
dry = 0
for mm in days:
if mm == 0:
dry += 1
return sum(days), max(days), dry
week = [0, 12, 30, 0, 8, 5, 0]
answer = rainfall(week)
print(answer, type(answer))
total, highest, dry = rainfall(week)
print("Total", total, "Highest", highest)
print("Dry days", dry)Output
(55, 30, 3) <class 'tuple'> Total 55 Highest 30 Dry days 3
Values separated by commas come back as a single tuple. Unpack it into as many names as there are values.
Use return when the question says return, and print() when it says display. They are not the same thing to the caller.
Here double_print(6) shows 12 on its own line and hands back None. The other function shows nothing and hands back 12.
def double_print(n):
print(n * 2)
def double_return(n):
return n * 2
x = double_print(6)
y = double_return(6)
print(x, y)Output
12 None 12
Q4. Which variable does this name mean?
A variable made inside a function is local: it exists only while that call runs. A variable made outside every function is global: any function may read it, but only a function that declares it with global may assign to it.
| Inside the function | What happens with a global fee = 500 | Value of fee afterwards |
|---|---|---|
print(fee) | No assignment, so Python finds the global and prints 500 | 500 |
fee = 800 | Makes a new local fee. The global is hidden, not changed | 500 |
global fee then fee = 800 | The assignment is made on the global itself | 800 |
fee = fee + 50 | Assignment makes fee local, and it is read before it has a value: UnboundLocalError | Program stops |
def show(fee): | The parameter is a local name, separate from the global one | 500 |
stock = 20
def sell(qty):
global stock
stock = stock - qty
return stock
def gift(stock):
stock = stock - 1
return stock
print(sell(5), stock)
print(gift(stock), stock)
stock = stock + 10
print(sell(gift(8)), stock)Output
15 15 14 15 18 18
| Statement | Global stock | Local stock | Printed |
|---|---|---|---|
sell(5) | 20 becomes 15 | none | 15 15 |
gift(stock) | 15 | 15 becomes 14 | 14 15 |
stock = stock + 10 | 25 | none | |
gift(8) | 25 | 8 becomes 7 | |
sell(7) | 18 | none | 18 18 |
Keep one column for the global and one for the locals, and draw a line when a call ends: the locals vanish there. This is the habit we build in class, as most wrong answers come from holding two variables with the same name in the head.
More trace practice: Class 12 output questions.
Q5. How are function answers marked?
In the 2026-27 marking scheme, a 2-mark function gives half a mark for the definition, one for the logic and half for the output line; a 3-mark one gives half, two and half. So a correct header and a correct last line are safe marks even when the logic wobbles.
def odd_letters(text):
"""Return the letters at index 1, 3, 5..."""
result = ""
for i in range(1, len(text), 2):
result = result + text[i]
return result
print(odd_letters("Brahmaputra"))Output
rhaur
Half: header. One: loop with a step of 2. Half: return.
def station_codes(names):
"""Return a list of 3-letter codes."""
codes = []
for name in names:
codes.append(name[:3].upper())
return codes
print(station_codes(["Nagpur", "Itarsi", "Bhopal"]))Output
['NAG', 'ITA', 'BHO']
The list must be created before the loop. Inside it, every pass would start again.
def late_fine(days, rate=2):
"""First 7 days at rate, later days at double."""
if days <= 7:
return days * rate
return 7 * rate + (days - 7) * rate * 2
print(late_fine(5))
print(late_fine(10))
print(late_fine(10, 3))Output
10 26 39
No else is needed: the first return has already ended the function.
def length_table(words):
"""Return {word: length} for words over 4 letters."""
table = {}
for w in words:
if len(w) > 4:
table[w] = len(w)
return table
print(length_table(["kite", "monsoon", "river", "sun"]))Output
{'monsoon': 7, 'river': 5}Half: header. Two: loop, test and assignment by key. Half: return.
bags = (("Asha", 14), ("Vikram", 19), ("Noor", 22))
def heavy_bags(data, limit=15):
"""Display owners over the limit, return how many."""
count = 0
for owner, kg in data:
if kg > limit:
print(owner, "is over by", kg - limit)
count += 1
return count
print("Bags charged:", heavy_bags(bags))
print("Bags charged:", heavy_bags(bags, 20))Output
Vikram is over by 4 Noor is over by 7 Bags charged: 2 Noor is over by 2 Bags charged: 1
One call displays and returns, so read the question for both verbs.
import math
def boxes_needed(laddoos, per_box=12):
"""Return how many boxes hold all the laddoos."""
return math.ceil(laddoos / per_box)
print(boxes_needed(36))
print(boxes_needed(40))
print(boxes_needed(40, 25))Output
3 4 2
Three kinds of function meet here: print() is built in, ceil() comes from a module, and boxes_needed() is yours.
For the report file, see the Class 12 practical file programs. The same writing style carries straight into file handling and the stack.
Q6. Can you answer these with the notes closed?
Eighteen original questions follow, in the one, two and three mark shapes that the 083 paper uses. Write each answer on paper before you open ours.
def pack(item, qty=1, gift=False): which call fails? (a) pack("Pen") (b) pack("Pen", 3) (c) pack() (d) pack("Pen", 3, True) item has no default, so a TypeError is raised.None, whose type is NoneType.sqrt() in math.sqrt(49) is which type of function? return p, q, r send back? return? def area(side): and area(9), side is the parameter and 9 is the argument.len(). A user defined function is written by the programmer with def and must be defined before it is called.print(late_fine) not show a fine? print(late_fine(5)).count_endings(words, letter="a") to return how many words end with the given letter. def count_endings(words, letter="a"):
count = 0
for w in words:
if w.endswith(letter):
count += 1
return count
print(count_endings(["Ganga", "Beas", "Yamuna"]))
print(count_endings(["Ganga", "Beas", "Yamuna"], "s"))Output
2 1
top_scorer(runs) to return the name and runs of the highest scorer, without using max(). def top_scorer(runs):
best_name, best = "", -1
for name in runs:
if runs[name] > best:
best_name, best = name, runs[name]
return best_name, best
print(top_scorer({"Anu": 34, "Reena": 71, "Kavya": 52}))Output
('Reena', 71)Looking for functions class 12 previous year questions? CBSE puts its own papers and marking schemes on its website, and those are the ones to trust. After a past paper, use this page to repair whichever type you missed. A full mixed set is on Class 12 CS important questions.
def mix(a, b=3):
a = a + b
b = a - b
return a, b
x, y = mix(7)
print(x, y)
x, y = mix(y, x)
print(x, y)10 717 7def scramble(word, step=2):
out = ""
for i in range(0, len(word), step):
out = word[i] + out
return out
print(scramble("MONSOON"))
print(scramble("MONSOON", 3))NONMNSMcount = 1
def step(n):
global count
count = count * n
return count
for i in range(1, 4):
print(step(i), end="#")
print(count)1#2#6#6def half(n):
return n // 2
def add(n, more=1):
return n + more
print(half(add(9)), add(half(9), 10))5 14def Average(marks)
total = 0
for m in marks:
total =+ m
Return total / len(marks)
print(average([40, 50, 60]))def Average(marks): # 1. colon
total = 0
for m in marks:
total += m # 2. +=, not =+
return total / len(marks) # 3. small r
print(Average([40, 50, 60])) # 4. same nameOutput
50.0
In a one to one class you write the header and the return line before anything else, since those are marks no logic error can take away.
The teacher alters a call, a default or a global line in your own program and asks for the new output before you run it.
Your answer is split into halves and ones beside you, so you learn where marks come from and stop guessing.
Next chapter in the syllabus: exception handling for Class 12. For the other chapters, go to Class 12 CS notes.
One student, one teacher
A wrong scope idea can survive a whole year if nobody sees you trace. Classes are personalised one to one only, on days you choose and at your own timing, so the teacher sees the line where you hesitate. Begin with a priority demo: it is a full class, and its fee is adjusted against your first month if you enrol. If you only want a short look, take the free demo class. You pay month by month with no admission fee, and may stop at the end of any month.
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
Some students need two sessions on this chapter and others need a month, because the gap is often in Class 11 loops and lists and not in def at all. One to one lets the plan follow that. The monthly fee is the one on this page, in the currency of your country.
Studying outside India?
CBSE schools in Dubai, Doha, Kuwait City or Kathmandu teach the same 083 functions line and sit the same paper, so the class is the same too. Only the clock changes, and you set it.
| 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 |
You need a computer with Python installed and a screen to share. Some students join from a school laptop in the evening and some before school. Tell us your free hours and we look for a teacher who fits them.
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 this chapter
A function is a named block of code that runs when it is called, can take values through parameters, and can return values. CBSE 083 for 2026-27 covers built-in functions, functions defined in a module and user defined functions, with positional and default parameters, return values, flow of execution and scope of a variable.
CBSE gives no separate figure. Functions belong to Unit 1, Computational Thinking and Programming 2, which carries 40 of the 70 theory marks. In the 2026-27 sample paper they appear directly in 1, 2 and 3 mark questions, and most file and stack answers are written as functions as well.
A positional argument is matched to a parameter by its place in the call and must be supplied if that parameter has no default. A default parameter has a value in the header, used only when the call leaves that argument out. In the header, parameters with defaults come after those without.
The 083 syllabus for 2026-27 lists default parameters and positional parameters. Keyword arguments are not named. It still helps to recognise a call such as tour(rate=300, seats=2), where the parameter name is written in the call and the order no longer matters.
Scope is the part of the program where a name can be used. A global variable is created outside all functions and can be read anywhere in the program. A local variable is created inside a function, including its parameters, and disappears when that call ends.
Because the function assigns to a name somewhere in its body, Python treats that name as local for the whole function. If you read it before that assignment, it has no value yet. Either pass the value in as a parameter and return the result, or declare the name with global.
No. Recursion does not appear in the 083 syllabus for Class 12 in 2026-27, and neither does *args. If a book or an old list includes recursive programs, leave them until you have finished functions, files and the stack.
CBSE puts its question papers and marking schemes on its own website. Practise from those, and check the year, because the syllabus has changed over time. The 18 questions here are our own, in the same shapes, so they are useful after the official ones are finished.
It can return several values separated by commas, and Python sends them back as one tuple. You may keep the tuple in one variable or unpack it, as in total, highest, dry = rainfall(week). The number of names must match the number of values.
Yes. Modern Age Coders teaches 083 live and one to one, at days and times you pick. A priority demo is a full class of about 45 to 60 minutes with a written skill report, its fee adjusted against the first month if you join. A free demo class is also available.
Start
Bring it to the free demo class and the teacher will start it with you: header, parameters, what must come back, then the loop in between.
To test the chapter properly, choose a priority demo at a slot that suits you. You write, trace and correct for a whole class, and the skill report tells you which of the four areas needs work: arguments, flow, return or scope. The fee counts towards the first month if you carry on.
Revising alone this week? Try the Class 12 CS MCQ test after the one-mark set above.
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