Skip to content
Computer ScienceCBSE Class 12 · Functions

Positional and Default Parameters in Python Functions (Class 12 Computer Science)

Updated 16 October 2026 · Fact-checked

Parameters are the names in a function header; arguments are the values passed in a call. Positional parameters receive arguments in order, so the count must match. A default parameter, such as rate=8, takes its default when no argument is given. Default parameters must come after all parameters without defaults.

Arguments fill parameters left to right; any parameter left without an argument uses its default, so defaults must come last.

Illustration drawn for QuestionBuddy.

Understand Positional and Default Parameters

In def interest(p, r, t): the names p, r and t are parameters (also called formal parameters). In the call interest(1000, 8, 2) the values 1000, 8 and 2 are arguments (actual parameters). When the function is called, each parameter is bound to an argument and then behaves like a local variable (NCERT Class XI 7.3.2).

Positional parameters. Arguments are matched to parameters by position: the first argument to the first parameter, and so on. Two things follow:

  • The order matters. info(16, 'Ria') for def info(name, age) makes name 16 and age 'Ria'. Python does not complain; the output is simply wrong.
  • The number must match. Too few arguments raises TypeError: f() missing 1 required positional argument: 'b'; too many raises TypeError: f() takes 2 positional arguments but 3 were given.

Default parameters. A parameter can be given a value in the header: def interest(p, r=8, t=1):. If the call supplies an argument for it, that argument is used; if not, the default is used. So interest(1000) uses r = 8 and t = 1, interest(1000, 10) uses r = 10 and t = 1, and interest(1000, 10, 2) uses all three arguments. Defaults make a function flexible: common cases need fewer arguments.

The trailing rule. Because arguments are matched left to right, once a parameter has a default, every parameter to its right must also have one. def f(a, b=1, c=2) is valid; def f(a=1, b) is a SyntaxError (Python 3.12 says 'parameter without a default follows parameter with a default'). NCERT states it as: default parameters must be the trailing parameters.

Arguments of different types. An argument can be a number, string, list, tuple or dictionary. If a list is passed and the function changes its contents (append, item assignment), the caller sees the change, because parameter and argument name the same list. Passing an int or string cannot change the caller's variable, because those are immutable.

The syllabus wording is 'arguments and parameters, default parameters, positional parameters'. Board items ask you to pick the valid header, predict the output of calls that use some defaults, or write a function with a default parameter, such as a 2-3 mark program in which a value like a rate or a separator has a default.

Positional and Default Parameters: key facts

Terms
Parametername in the function header (formal parameter)
Argumentvalue given in the call (actual parameter)
Positional parametergets the argument at the same position
Default parameterhas a value in the header, used when no argument is given
Parameters are local variables of the function.
Matching rule
  • interest(1000) → p = 1000, r = 8, t = 1
  • interest(1000, 10) → r = 10, t = 1
  • interest(1000, 10, 2) → r = 10, t = 2
For def interest(p, r=8, t=1); arguments fill parameters left to right.
Valid and invalid headers
def f(a, b=1, c=2)valid
def f(a, b, c=2)valid
def f(a=1, b)SyntaxError
def f(a=1, b, c=2)SyntaxError
Defaults must be the trailing parameters.
Errors from a wrong number of arguments
Too fewTypeError: missing required positional argument
Too manyTypeError: takes n positional arguments but m were given
Wrong orderno error, wrong result
Read the error type carefully in MCQs: these are TypeErrors, not SyntaxErrors.

How to answer Positional and Default Parameters questions

For output questions with parameters, match every argument before running the body.

  1. 1Write the header and list the parameters with their default values, if any.
  2. 2For each call, fill the parameters from left to right with the arguments given.
  3. 3Any parameter left without an argument takes its default; if it has no default, the call raises TypeError (missing argument).
  4. 4If there are more arguments than parameters, the call raises TypeError (too many arguments).
  5. 5Run the body with these values; remember that parameters are local.
  6. 6For header-validity MCQs, check that no parameter without a default comes after one with a default.
  7. 7In programs you write, put the parameters the question says are optional at the end with sensible defaults.

Positional and Default Parameters in real life

The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.

Default parameters for the common case

Suppose a cinema's ticket function charges ₹200 per seat unless the customer picks a premium seat, and books 1 seat unless told otherwise.

Write ticket(name, seats=1, rate=200) that returns a message with the total, and show three calls: only a name; a name and 3 seats; a name, 2 seats and rate 350.

Try it first, then show the solutionSolution
  1. Only the name is required, so it comes first; the optional values come last with defaults.
  2. def ticket(name, seats=1, rate=200):
        return name + ': Rs ' + str(seats * rate)
    print(ticket('Kabir'))
    print(ticket('Meera', 3))
    print(ticket('Joel', 2, 350))

Answer: Kabir: Rs 200
Meera: Rs 600
Joel: Rs 700

Memory hook: Defaults are the 'usual order' at a shop: say nothing and you get the usual.

Positional order matters

Imagine a form-printing function label(name, city) used to print parcel labels, and a clerk types label('Pune', 'Asha') by mistake.

What is printed, and does Python report an error?

Try it first, then show the solutionSolution
  1. Arguments match by position: name = 'Pune', city = 'Asha'.
  2. def label(name, city):
        print('To:', name, '| City:', city)
    label('Pune', 'Asha')
    label('Asha', 'Pune')

Answer: To: Pune | City: Asha (no error, just a wrong label); the correct call prints To: Asha | City: Pune.

Memory hook: Positional arguments are seats in a row: whoever sits in seat 1 is called 'name'.

Tricks to remember Positional and Default Parameters

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • Header has Parameters, call has Arguments

    P for Plan (header), A for Action (call).

    Use it when: Defining the two terms.

  • Defaults sit at the back of the bus

    Once someone with a default sits down, everyone behind must have a default too.

    Use it when: Valid-header MCQs.

  • Fill from the left

    Arguments fill seats from the left; empty seats take their default or cause a TypeError.

    Use it when: Predicting values in partial calls.

  • Count errors are TypeErrors

    Wrong number of arguments: TypeError at the call. Wrong header order: SyntaxError before anything runs.

    Use it when: Error-identification items.

Positional and Default Parameters: solved examples

Ordered from board level to HOTS. Try each one before you open the solution.

Example 1: Calls that use some defaults · 1 mark · Very short answerBoard level

Write the output:

def interest(p, r=8, t=1):
    return p * r * t / 100
print(interest(1000), interest(1000, 10), interest(1000, 10, 2))
Try it first, then show the solutionSolution
  1. First call: r = 8, t = 1 → 80.0. Second: r = 10, t = 1 → 100.0.
  2. Third: r = 10, t = 2 → 200.0. / always gives a float.

Answer: 80.0 100.0 200.0

Example 2: Which header is valid? · 1 mark · MCQHarder board level

Which of the following function headers is valid in Python?
(a) def area(l=5, b): (b) def area(l, b=5): (c) def area(l=5, b, h=2): (d) def area(=5, b):

Try it first, then show the solutionSolution
  1. (a) and (c) put a parameter without a default after one with a default: SyntaxError.
  2. (d) is not a parameter at all. Only (b) has its default at the end.

Answer: (b) def area(l, b=5):

Example 3: Wrong order, no error · 2 marks · Short answerHarder board level

Predict the output:

def info(name, age=15):
    print(name, 'is', age)
info('Ria')
info(16, 'Ria')
Try it first, then show the solutionSolution
  1. info('Ria'): name = 'Ria', age takes its default 15. (1 mark)
  2. info(16, 'Ria'): matched by position, so name = 16 and age = 'Ria'; Python prints them without complaint. (1 mark)

Answer: Ria is 15
16 is Ria

Example 4: Writing functions with defaults · 3 marks · Short answerHarder board level

Write a function power(base, exp=2) that returns base raised to exp, and a function line(ch='-', n=10) that prints ch n times. Show the output of power(5), power(2, 5), line() and line('*', 4).

Try it first, then show the solutionSolution
  1. Headers with trailing defaults (1 mark); return in power and print in line (1 mark); correct calls (1 mark).
  2. def power(base, exp=2):
        return base ** exp
    def line(ch='-', n=10):
        print(ch * n)
    print(power(5), power(2, 5))
    line()
    line('*', 4)

Answer: 25 32
----------
****

Example 5: Identify the error in each call · 2 marks · Short answerHOTS / competency

For def avg(a, b, c=0): return (a + b + c) / 3, state the result or the error of each call: (i) avg(3, 6) (ii) avg(3) (iii) avg(3, 6, 9, 12)

Try it first, then show the solutionSolution
  1. (i) c defaults to 0: (3 + 6 + 0) / 3 = 3.0. (½ mark)
  2. (ii) b has no default and no argument: TypeError: avg() missing 1 required positional argument: 'b'. (½ mark)
  3. (iii) Four arguments for three parameters: TypeError: avg() takes from 2 to 3 positional arguments but 4 were given. (1 mark)
  4. def avg(a, b, c=0):
        return (a + b + c) / 3
    print(avg(3, 6))
    try:
        avg(3)
    except TypeError as e:
        print(e)
    try:
        avg(3, 6, 9, 12)
    except TypeError as e:
        print(e)

Answer: (i) 3.0 (ii) TypeError: missing 1 required positional argument: 'b' (iii) TypeError: takes from 2 to 3 positional arguments but 4 were given

Example 6: Case study: a shop's bill function · 4 marks · Case-basedHOTS / competency

Suppose a stationery shop writes bill(price, qty=1, disc=0) that returns price × qty reduced by disc percent.
(i) Write the function. (2 marks)
(ii) Give the outputs of bill(50), bill(50, 4) and bill(50, 4, 10). (1 mark)
(iii) The owner wants the discount to be required and the quantity optional, and writes def bill(price, qty=1, disc). Why is this rejected, and what is a valid header? (1 mark)

Try it first, then show the solutionSolution
  1. (i)
    def bill(price, qty=1, disc=0):
        amt = price * qty
        return amt - amt * disc / 100
    print(bill(50), bill(50, 4), bill(50, 4, 10))
  2. (ii) 50.0, 200.0 and 180.0 (the / makes each result a float).
  3. (iii) disc has no default but comes after qty, which has one: SyntaxError. Put the required parameter first: def bill(price, disc, qty=1).

Answer: (ii) 50.0 200.0 180.0 (iii) A non-default parameter cannot follow a default one; use def bill(price, disc, qty=1).

Where students lose marks in Positional and Default Parameters

The slips examiners see most often, and what to write instead.

  • Mistake: Putting a default before a required parameter

    Arguments fill from the left, so Python rejects a required parameter after a default one.

    Wrong working

    def total(rate=5, amount):

    Right working

    def total(amount, rate=5):

    Do this: List required parameters first, then the ones with defaults.

    Usually costs: Half to 1 mark.

  • Mistake: Mixing up parameters and arguments

    The terms are defined by where they appear: header or call.

    Wrong working

    In def area(l, b), l and b are arguments.

    Right working

    In def area(l, b), l and b are parameters; in area(4, 7), 4 and 7 are arguments.

    Do this: Give the definition with a two-line example marking each.

    Usually costs: 1 mark.

  • Mistake: Assuming Python reorders positional arguments

    Without keywords, arguments go strictly by position.

    Wrong working

    info(16, 'Ria') → Ria is 16

    Right working

    info(16, 'Ria') → 16 is Ria

    Do this: Match each argument to the parameter in the same position.

    Usually costs: 1 mark.

  • Mistake: Calling the argument-count error a SyntaxError

    A wrong number of arguments is detected when the call runs, as TypeError.

    Do this: SyntaxError: badly written header or code. TypeError: wrong number of arguments at a call.

    Usually costs: 1 mark in MCQs.

Exam tips

  • When a question says a value is 'optional' or 'by default ...', make it a default parameter at the end of the header.
  • Show at least one call that uses the default and one that overrides it; examiners look for both.
  • In MCQs on headers, check only one thing: is every parameter after the first default also given a default?
  • If a list is passed and changed inside the function, the caller's list changes too; mention this when explaining outputs.
  • Use the syllabus words in definitions: 'positional parameters', 'default parameters', 'arguments and parameters'.

Practice questions on Positional and Default Parameters

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQBoard level

    The values passed to a function at the time of calling it are called:
    (a) parameters (b) arguments (c) defaults (d) returns

    Hint

    Header or call?

    Answer

    (b) arguments

  2. Q2 · 1 mark · Very short answerBoard level

    Write the output:

    def f(x, y=3):
        return x * y
    print(f(2), f(2, 5))
    Hint

    The first call uses the default.

    Answer

    6 10

  3. Q3 · 1 mark · Very short answerBoard level

    In the code below, name the parameters and the arguments.

    def area(l, b):
        return l * b
    print(area(4, 7))
    Hint

    P for Plan, A for Action.

    Answer

    Parameters: l and b. Arguments: 4 and 7. Output 28.

  4. Q4 · 2 marks · Short answerHarder board level

    Write the output:

    def wish(n, msg='Good morning'):
        return msg + ', ' + n
    print(wish('Tara'))
    print(wish('Good night', 'Tara'))
    Hint

    The second call fills n first.

    Answer

    Good morning, Tara
    Tara, Good night

  5. Q5 · 2 marks · Short answerHarder board level

    Write a function percent(marks, total=500) that returns the percentage rounded to 2 decimal places with round(). Print percent(437) and percent(72, 80).

    Hint

    round(value, 2).

    Answer
    def percent(marks, total=500):
        return round(marks / total * 100, 2)
    print(percent(437), percent(72, 80))

    Output: 87.4 90.0

  6. Q6 · 1 mark · Assertion-reasonHarder board level

    Assertion (A): def f(a=2, b): is an invalid function header.
    Reason (R): A parameter without a default value cannot follow a parameter with a default value.
    (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.

    Hint

    Back of the bus.

    Answer

    (a) Both are true and R explains A.

  7. Q7 · 2 marks · Short answerHOTS / competency

    Predict the output:

    def add(L, x=0):
        L.append(x)
        return len(L)
    M = [1]
    print(add(M), add(M, 5), M)
    Hint

    The list argument is the caller's list; the calls run left to right before printing.

    Answer

    2 3 [1, 0, 5]. The first call appends the default 0, the second appends 5, and both change M.

Test your recall

Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.

  1. 1.What is a default parameter?Show answer

    A parameter given a value in the header, used when the call gives no argument for it.

  2. 2.Is def f(a, b=2, c=3) valid?Show answer

    Yes; the defaults are at the end.

  3. 3.What error does calling f(1) give for def f(a, b)?Show answer

    TypeError: f() missing 1 required positional argument: 'b'.

  4. 4.What does def f(a=1, b) give?Show answer

    SyntaxError: parameter without a default follows parameter with a default.

  5. 5.How are positional arguments matched?Show answer

    By order: first argument to first parameter, and so on.

  6. 6.What is another name for a parameter?Show answer

    Formal parameter (an argument is also called an actual parameter).

Positional and Default Parameters: frequently asked questions

What is the difference between an argument and a parameter?

A parameter is a name in the function header, such as l and b in def area(l, b). An argument is the value supplied in the call, such as 4 and 7 in area(4, 7).

Why must default parameters come at the end?

Arguments are matched from the left. If a required parameter came after a default one, Python could not tell which argument belongs where, so the header is a SyntaxError.

Are keyword arguments in the Class 12 CBSE syllabus?

The 2026-27 syllabus names arguments and parameters, positional parameters and default parameters. Board questions on this topic use positional calls and defaults, so practise those first.

Can a list be passed as an argument?

Yes. Any object can be passed. If the function changes the list's contents, the caller's list changes too, because both names refer to the same list.