Placement Prep

Function Arguments in Python: 5 Types Explained

Learn all five Python argument types: positional, keyword, default, *args, and **kwargs, with code examples and the ordering rules that placement tests check.

By FACE Prep Team 4 min read
python functions arguments placement-prep crt-training beginners programming

Python functions accept arguments in five distinct ways, and placement tests regularly probe whether you know the ordering rules, not just the syntax.

This article covers all five types with verified code examples and the one signature rule that produces a SyntaxError when broken.

Parameters vs. Arguments

The two words are not synonyms, even though they’re used interchangeably in most tutorials.

A parameter is the variable name declared in the function definition. An argument is the value you supply when calling that function. The Python language reference draws this line explicitly.

def greet(name):        # 'name' is a parameter
    print("Hello,", name)

greet("Priya")          # "Priya" is an argument

Output:

  • Hello, Priya

Getting the terminology right matters in interviews. An interviewer who hears “I passed the wrong parameter” when you mean argument notices the slip.

Positional and Keyword Arguments

These two types answer the same question (how does a caller assign values to parameters?), but with different mechanics.

Positional Arguments

Positional arguments are matched to parameters strictly by position: first argument goes to first parameter, second to second, and so on.

def employee(name, age, salary):
    print("Name:", name)
    print("Age:", age)
    print("Salary:", salary)

employee("Arjun", 22, 18000)

Output:

  • Name: Arjun
  • Age: 22
  • Salary: 18000

Swap the order of arguments and the values land in the wrong parameters (no error, just wrong output). That silent failure is the common mistake.

Keyword Arguments

Keyword arguments name the parameter explicitly. Order no longer matters.

employee(salary=21000, name="Meena", age=23)

Output:

  • Name: Meena
  • Age: 23
  • Salary: 21000

The same employee function works without modification. Keyword arguments are particularly useful when a function has several optional parameters and you want to specify only one of them.

You can mix both styles in one call, but positional arguments must come first:

employee("Arjun", salary=18000, age=22)   # valid
employee(name="Arjun", 22, 18000)         # SyntaxError

Default Arguments

Default arguments give a parameter a fallback value. If the caller does not supply that argument, the default is used.

def employee(name, age=23, salary=20000):
    print("Name:", name)
    print("Age:", age)
    print("Salary:", salary)

employee(name="Jack", age=22)
employee(name="John", salary=21000)

Output for the first call:

  • Name: Jack
  • Age: 22
  • Salary: 20000 (default applied)

Output for the second call:

  • Name: John
  • Age: 23 (default applied)
  • Salary: 21000

The constraint: a non-default parameter cannot follow a default parameter. This is a SyntaxError at definition time, not at call time.

def broken(name="Unknown", age):   # SyntaxError
    pass

Python cannot figure out which argument fills age when name already has a default. Keep defaults at the end of the positional parameter list.

There is a second, subtler trap: avoid using a mutable object (a list or a dictionary) as a default value. Python evaluates defaults once, at function-definition time, not fresh on every call. A shared mutable default accumulates state across calls.

# common mistake
def append_item(item, lst=[]):
    lst.append(item)
    return lst

print(append_item(1))   # [1]
print(append_item(2))   # [1, 2] -- not [2] as many students expect

The standard fix is to use None as the default and create the list inside the function body: if lst is None: lst = []. This pattern appears in campus CRT rounds and in entry-level Python interviews.

Variable-Length Arguments: *args and **kwargs

Sometimes a function should accept an arbitrary number of arguments. Python provides two mechanisms: *args for extra positional values and **kwargs for extra keyword values.

*args

The *args syntax collects all extra positional arguments into a tuple. The name args is a convention; the asterisk is what matters.

def total(*nums):
    result = 0
    for n in nums:
        result += n
    return result

print(total(10, 20, 30))
print(total(5, 15))

Output:

  • 60
  • 20

See how summing a list of values handles the same accumulation pattern with a fixed-length input.

**kwargs

**kwargs collects all extra keyword arguments into a dictionary. Keys are the argument names, values are the supplied values.

def show_info(**details):
    for key, value in details.items():
        print(f"{key}: {value}")

show_info(language="Python", level="Intermediate", days=45)

Output:

  • language: Python
  • level: Intermediate
  • days: 45

The distinction matters in assessments: *args produces a tuple, **kwargs produces a dict. Both types are documented in the Python tutorial on defining functions.

Combining All Five: Signature Order Rules

When a function uses multiple argument types, the parameters must appear in a fixed order. Break it and Python raises a SyntaxError before the function is ever called.

The required order is:

PositionArgument typeExample
1Regular positional parametersname, age
2*args*extra
3Keyword parameters with defaultscountry="India"
4**kwargs**meta

A correctly ordered signature looks like:

def register(name, age, *tags, country="India", **meta):
    print(name, age, tags, country, meta)

register("Kiran", 21, "python", "crt", city="Chennai", batch=2026)

Output:

  • Kiran 21 ('python', 'crt') India {'city': 'Chennai', 'batch': 2026}

country is a keyword-only parameter here: it sits after *tags so it can only be set by name, not by position. This pattern appears in CRT assessments and is a common interview question for campus hiring at mid-size IT firms.

A working calculator program in Python demonstrates how these argument types interact in a small but complete function. More beginner-level programs that combine these concepts are in the Python practice programs collection.

Where This Matters Beyond Placement Tests

Understanding **kwargs is not only a test-prep skill. Python SDKs for AI tools (including the openai and anthropic libraries) use **kwargs-style signatures extensively to forward optional parameters without breaking the caller interface. If you have the ordering rule correct in your head, reading that kind of function signature takes seconds, not minutes.

TinkerLLM is a hands-on playground where you write real Python functions that call LLM APIs; the same *args and **kwargs patterns from this article appear in every wrapper function you build there. It costs ₹299 to start.

Primary sources

Frequently asked questions

What is the difference between a parameter and an argument?

A parameter is the variable name in the function definition. An argument is the actual value you pass when calling that function. In def greet(name):, name is the parameter. In greet('Priya'), 'Priya' is the argument.

What happens if I pass too few arguments to a Python function?

Python raises a TypeError at runtime: 'missing X required positional argument(s)'. Every non-default parameter must receive a value, either positionally or by keyword, when the function is called.

When should I use *args instead of passing a list directly?

Use *args when callers should not need to construct a list first. def add(*nums) lets you call add(1, 2, 3) instead of add([1, 2, 3]). Inside the function, nums is a tuple either way.

Can I mix positional and keyword arguments in one call?

Yes, with one constraint: all positional arguments must come before keyword arguments in the call. greet('Priya', age=21) is valid; greet(name='Priya', 21) raises a SyntaxError.

What is the correct order of argument types in a function signature?

The required order is: positional parameters first, then *args, then keyword parameters with defaults, then **kwargs. Placing a non-default parameter after a default one raises a SyntaxError.

Can a function have both *args and **kwargs?

Yes. def func(*args, **kwargs) is valid and common. *args captures extra positional values; **kwargs captures extra keyword values. Both can appear together, with *args listed before **kwargs.

Build AI projects

A self-paced playground for building with LLMs.

TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.

Try TinkerLLM (₹299 launch)
Free AI Roadmap PDF