Ad – 728Γ—90
βš™οΈ Functions

Python Function Parameters and Arguments – Complete Guide

Parameters are the variables listed in a function definition. Arguments are the actual values passed when calling the function. Python's parameter system is one of its most flexible features β€” supporting positional, keyword, default, variadic, and keyword-only parameters.

⏱️ 22 min read 🎯 Beginner πŸ“… Updated 2026

Positional Parameters

The most basic type. Arguments match parameters by position β€” first argument goes to first parameter, second to second, etc.

Python
def greet(first_name, last_name):
    print(f"Hello, {first_name} {last_name}!")

greet("Alice", "Smith")   # Alice β†’ first_name, Smith β†’ last_name
greet("Bob", "Jones")
β–Ά Output
Hello, Alice Smith! Hello, Bob Jones!

Default Parameter Values

Parameters can have default values β€” used when the caller doesn't provide that argument.

Python
def power(base, exponent=2):  # exponent defaults to 2
    return base ** exponent

print(power(5))       # 25 - uses default exponent=2
print(power(5, 3))    # 125 - overrides default
print(power(2, 10))   # 1024
β–Ά Output
25 125 1024
πŸ’‘
Tip

Always put parameters with default values AFTER parameters without defaults, or you get a SyntaxError.

Ad – 336Γ—280

*args – Variable Positional Arguments

*args collects any number of positional arguments into a tuple.

Python
def sum_all(*numbers):  # numbers is a tuple
    print(f"Received: {numbers}")
    return sum(numbers)

print(sum_all(1, 2, 3))           # 6
print(sum_all(10, 20, 30, 40))    # 100
print(sum_all())                   # 0 - empty tuple
β–Ά Output
Received: (1, 2, 3) 6 Received: (10, 20, 30, 40) 100 Received: () 0

**kwargs – Variable Keyword Arguments

**kwargs collects any number of keyword arguments into a dictionary.

Python
def print_info(**details):  # details is a dict
    for key, value in details.items():
        print(f"  {key}: {value}")

print_info(name="Alice", age=25, city="London")
β–Ά Output
name: Alice age: 25 city: London

Parameter Order – The Golden Rule

When combining parameter types, order matters: regular β†’ *args β†’ keyword-only β†’ **kwargs.

Python
# Full parameter order example
def full_function(a, b, c=10, *args, keyword_only=99, **kwargs):
    print(f"a={a}, b={b}, c={c}")
    print(f"args={args}")
    print(f"keyword_only={keyword_only}")
    print(f"kwargs={kwargs}")

full_function(1, 2, 3, 4, 5, keyword_only="hello", x=100)
β–Ά Output
a=1, b=2, c=3 args=(4, 5) keyword_only=hello kwargs={'x': 100}