CBSE Class 12 · Computer Science 083 · Functions chapter 2026-27

Functions class 12 computer science: notes, argument rules, scope and questions.

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

Where this chapter is taught

One course covers the whole 083 syllabus. The other two build the Python fluency and the database half around it.

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?

Functions in Python Class 12 notes: what must you know?

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 functionWhere it comes fromWhat you do before using itExample
Built-inAlready part of PythonNothing, just call itlen(name), max(marks)
Defined in a moduleA module such as math or randomImport the modulemath.ceil(4.2), random.randint(1, 6)
User definedYou write it with defDefine it above the callparcel_charge(3)
Seven parts in six linesparcel.py
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
  • Header: the def line. It must end with a colon.
  • Parameters: weight and rate, the names that receive values.
  • Docstring: the first string in the body. It says what the function is for, which counts towards the documentation share of the lab test.
  • Body: the indented statements.
  • Return: sends charge back and ends the function.
  • Call: parcel_charge(3). No call, no output.
  • Argument: 3, the actual value sent to 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, default and keyword arguments in Class 12

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.

The function being calledone required, two defaults
def tour(seats, city="Mysuru", rate=250):
    return city + " " + str(seats * rate)
CallseatscityrateResult
tour(4)4Mysuru250'Mysuru 1000'
tour(4, "Ooty")4Ooty250'Ooty 1000'
tour(4, "Ooty", 300)4Ooty300'Ooty 1200'
tour(4, 300)4300250TypeError: 300 went to city, and a number cannot be joined to a string
tour()noneMysuru250TypeError: seats is required
tour(4, "Ooty", 300, 1)TypeError: four arguments for three parameters
tour(rate=300, seats=2)2Mysuru300'Mysuru 600' (keyword call)
tour(city="Ooty", 4)SyntaxError: a positional argument cannot follow a keyword one

Four rules to write in the margin

  1. Required first, defaults last

    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.

  2. Order decides

    Python does not read the names of your variables. The first argument goes to the first parameter, whatever it is called.

  3. A default is a spare value

    An argument that is passed always wins over the default.

  4. Same count, or a TypeError

    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.

When the argument is a list

Change it, or replace it?team.py
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?

Flow of execution and functions returning values

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.

Trace the line numberskettle.py
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")                       # 11

Output

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.

One return, three answersrain.py
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.

print or return: which one does the question want?

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.

What the caller receivesdouble.py
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?

Scope of variable in Class 12: global and local

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 functionWhat happens with a global fee = 500Value of fee afterwards
print(fee)No assignment, so Python finds the global and prints 500500
fee = 800Makes a new local fee. The global is hidden, not changed500
global fee then fee = 800The assignment is made on the global itself800
fee = fee + 50Assignment makes fee local, and it is read before it has a value: UnboundLocalErrorProgram stops
def show(fee):The parameter is a local name, separate from the global one500
A full scope tracegifts.py
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

The same trace, on paper

StatementGlobal stockLocal stockPrinted
sell(5)20 becomes 15none15 15
gift(stock)1515 becomes 1414 15
stock = stock + 1025none
gift(8)258 becomes 7
sell(7)18none18 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?

Important function programs for Class 12 Computer Science

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.

1. Letters at odd positions2 marks
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.

2. A new list of codes2 marks
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.

3. Library fine with a default rate3 marks
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.

4. Lengths in a dictionary3 marks
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.

5. A tuple of pairs3 marks
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.

6. Using a function from a module2 marks
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?

Functions Class 12 important questions, and previous year practice

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.

One mark

  1. For def pack(item, qty=1, gift=False): which call fails? (a) pack("Pen") (b) pack("Pen", 3) (c) pack() (d) pack("Pen", 3, True)
    Answer (c) pack(). item has no default, so a TypeError is raised.
  2. What value does a function give back if it has no return statement?
    Answer None, whose type is NoneType.
  3. State True or False: a variable created inside one function can be used in another function.
    Answer False. It is local to the function that made it.
  4. Fill in: a name in the def header is a ______, and a value in the call is an ______.
    Answer parameter, and argument.
  5. sqrt() in math.sqrt(49) is which type of function?
    Answer A function defined in a module. The module must be imported first.
  6. How many objects does return p, q, r send back?
    Answer One: a tuple holding three values.
  7. What happens to statements written in the same block after return?
    Answer They never run. The function has already ended.
  8. Assertion (A): A function can change the contents of a list passed to it. Reason (R): A list is mutable, and the parameter refers to the same list as the argument.
    Answer Both A and R are true, and R is the correct explanation of A. The team example above shows it.

Two marks, theory

  1. Differentiate between a parameter and an argument, with an example.
    Answer A parameter is a name in the function header that receives a value; an argument is the value supplied in the call. In def area(side): and area(9), side is the parameter and 9 is the argument.
  2. Differentiate between a built-in function and a user defined function.
    Answer A built-in function comes with Python and can be called directly, such as len(). A user defined function is written by the programmer with def and must be defined before it is called.
  3. Why does print(late_fine) not show a fine?
    Answer There are no brackets, so the function is not called. Python prints a description of the function object. Write print(late_fine(5)).

Writing a function

  1. (2 marks) Write count_endings(words, letter="a") to return how many words end with the given letter.
    Answer
    Q12one good answer
    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
  2. (3 marks) A dictionary holds runs by each player. Write top_scorer(runs) to return the name and runs of the highest scorer, without using max().
    Answer
    Q13one good answer
    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.

Two marks, output and errors

  1. Predict the output.
    Q14predict
    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)
    Answer Output
    10 7
    17 7
    First call: a is 7 + 3 = 10, then b is 10 - 3 = 7. The second call sends 7 and 10, in that order.
  2. Predict the output.
    Q15predict
    def 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))
    Answer Output
    NONM
    NSM
    Each new letter is put in front, so the picked letters come out reversed.
  3. Predict the output.
    Q16predict
    count = 1
    
    def step(n):
        global count
        count = count * n
        return count
    
    for i in range(1, 4):
        print(step(i), end="#")
    print(count)
    Answer Output
    1#2#6#6
    The same global is multiplied by 1, 2 and 3. There is no newline until the last print.
  4. Predict the output.
    Q17predict
    def half(n):
        return n // 2
    
    def add(n, more=1):
        return n + more
    
    print(half(add(9)), add(half(9), 10))
    Answer Output
    5 14
    Inner calls finish first: add(9) is 10 and its half is 5; half(9) is 4 and 4 + 10 is 14.
  5. Rewrite after removing all errors, and underline each correction.
    Q18four errors
    def Average(marks)
        total = 0
        for m in marks:
            total =+ m
        Return total / len(marks)
    print(average([40, 50, 60]))
    Answer
    Q18 correctedhalf a mark each
    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 name

    Output

    50.0

Blank page first

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.

Change one thing

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.

Marks shown on screen

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

You learn functions by writing them while someone watches

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

Priority demo, at a slot you pick

a full live class of about 45 to 60 minutes

  • You write one function from a question you have not seen
  • Your answer is marked in halves, as the board scheme does it
  • One scope trace on paper, to find which rule is shaky
  • A written skill report on defining, calling, returning and scope
Book a priority demo

The classes · Choose your own timing

Personalised one to one

₹4,999

per month, 4 private classes, fully flexible timing

  • Starts from your school test paper or your weakest question type
  • You type every program yourself, with the teacher on the call
  • Lists, strings and dictionaries from Class 11 repaired on the way
  • Files, stack and connectivity follow, all as functions
Ask for a personalised plan

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?

Learning the functions chapter from another country

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 liveTime differenceUsual class window, local timeFormat
India
every Indian city
Indian timeAny time you choosePersonalised 1-on-1
UAE and Oman
Dubai, Abu Dhabi, Sharjah, Muscat
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Saudi Arabia, Qatar, Kuwait, Bahrain
Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama
2 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Nepal
Kathmandu
15 min ahead of India4:30 PM to 9:00 PMPersonalised 1-on-1
Ethiopia and East Africa
Addis Ababa and East Africa Time
2 h 30 min behind India4:30 PM to 9:00 PMPersonalised 1-on-1
Singapore and Malaysia
Singapore, Kuala Lumpur
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 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

Rated 4.9 across 547 Google reviews

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

More pages for Class 12 students

Every page in the CBSE Class 12 Computer Science series, grouped by what you need.

Questions about this chapter

Functions in Class 12 Python: common questions

What are functions in Class 12 Computer Science?

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.

How many marks do functions carry in Class 12 Computer Science?

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.

What is the difference between positional and default arguments?

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.

Are keyword arguments in the CBSE Class 12 syllabus?

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.

What is the scope of a variable in Python Class 12?

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.

Why do I get UnboundLocalError in a function?

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.

Is recursion in the Class 12 Computer Science syllabus 2026-27?

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.

Where can I find functions class 12 previous year questions?

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.

Can a Python function return more than one value?

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.

Can I get one to one help with Python functions for Class 12?

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

Send one function you could not write.

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.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

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

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here