Python Function Arguments

Last Updated 13 Sep, 2026

When a function needs to work with different values, you can pass those values to it when calling the function. These values are called arguments. Python supports different ways of passing arguments, including positional arguments and keyword arguments.

What are Arguments?

An argument in Python is a value passed to a function when the function is called.

For example:

def greet(name):
   print("Hello", name)

greet("Rahul")

Output:

Hello Rahul

Here, "Rahul" is the argument passed to the greet() function.

The variable name in the function definition is called a parameter, while "Rahul" is the argument supplied during the function call.

Positional Arguments

Positional arguments are passed to a function based on their position. The first argument is assigned to the first parameter, the second argument to the second parameter, and so on.

def student(name, age):
   print("Name:", name)
   print("Age:", age)

student("Rahul", 21)

Output:

Name: Rahul
Age: 21

Here, "Rahul" is assigned to name and 21 is assigned to age.

The order matters with positional arguments:

student(21, "Rahul")

This assigns 21 to name and "Rahul" to age.

Keyword Arguments

With keyword arguments, you specify the parameter name when passing the value. Because the parameter names are provided, the order of the arguments does not matter.

def student(name, age):
   print("Name:", name)
   print("Age:", age)

student(age=21, name="Rahul")

Output:

Name: Rahul
Age: 21

Here, name="Rahul" and age=21 clearly tell Python which value belongs to which parameter.

You can also combine positional and keyword arguments:

def student(name, age, city):
    print(name, age, city)

student("Rahul", age=21, city="Delhi")

A positional argument must come before a keyword argument.

Passing Multiple Arguments

A function can accept multiple arguments as long as its parameters are defined accordingly.

def add(a, b, c):
    print(a + b + c)

add(10, 20, 30)

Output:

60

When you do not know in advance how many arguments will be passed, Python allows you to use *args.

def add(*numbers):
   print(sum(numbers))

add(10, 20, 30, 40)

Output:

100

Here, *numbers allows the function to receive any number of positional arguments.

For multiple keyword arguments, you can use **kwargs:

def student(**details):
    print(details)

student(name="Rahul", age=21, city="Delhi")

Output:

{'name': 'Rahul', 'age': 21, 'city': 'Delhi'}

*args collects multiple positional arguments, while **kwargs collects multiple keyword arguments.