Function Parameters and Arguments in Python

Function parameters and arguments are closely related, but they are not the same thing.

A parameter is a name written in a function definition. An argument is the actual value you pass to the function when you call it.

Understanding this difference makes it much easier to read Python functions, write your own functions, and fix function call errors.

Quick example

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

greet("Maya")
  • Parameter: name in the function definition
  • Argument: "Maya" in the function call

What this page teaches

By the end of this page, you should understand that:

  • Parameters are variable names in a function definition
  • Arguments are actual values passed when calling the function
  • You can read both parts of a simple function with confidence

If you are new to functions in general, see Python functions explained.

Parameter vs argument

Look at this function:

def add(a, b):
    return a + b

In the def line:

  • a is a parameter
  • b is a parameter

Now look at the function call:

add(2, 3)

In this call:

  • 2 is an argument
  • 3 is an argument

Python takes the arguments and assigns them to the parameters:

  • a = 2
  • b = 3

So the function can use those values inside its body.

Why functions use parameters

Parameters make functions flexible.

Without parameters, you would need to write a new function for every value. With parameters, one function can work with many different inputs.

Parameters are useful because they:

  • Make one function reusable with different values
  • Avoid repeating very similar code
  • Let input come from variables, user input, or calculations

For example:

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

greet("Maya")
greet("Sam")
greet("Ava")

The same function works for different names because it uses a parameter.

If you want to practice building functions from scratch, see how to create a simple function in Python.

Basic example with one parameter

Here is a simple function with one parameter:

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

greet("Maya")

How it works

  • name is the parameter
  • "Maya" is the argument
  • When the function runs, Python gives the value "Maya" to name

Inside the function, name behaves like a normal variable.

Output

Hello Maya

You can also pass a variable instead of writing the value directly:

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

person = "Leo"
greet(person)

Output:

Hello Leo

The outside variable is called person, but the parameter is called name. That is fine. The names do not need to match.

Example with multiple parameters

Functions can have more than one parameter.

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

add(2, 3)

Output:

5

Here:

  • a gets the first argument: 2
  • b gets the second argument: 3

The order matters with this style of function call.

For example:

def greet(first_name, last_name):
    print("Hello", first_name, last_name)

greet("Maya", "Lopez")

Output:

Hello Maya Lopez

If you reverse the arguments:

greet("Lopez", "Maya")

Output:

Hello Lopez Maya

The function still runs, but the result changes because the arguments were passed in a different order.

Positional arguments

When arguments are matched by order, they are called positional arguments.

Example:

def subtract(a, b):
    print(a - b)

subtract(10, 4)

Output:

6

Python matches them like this:

  • first argument 10 → parameter a
  • second argument 4 → parameter b

If you switch the order:

subtract(4, 10)

Output:

-6

That is why order matters with positional arguments.

For beginners, positional arguments are usually the easiest way to start calling functions.

Keyword arguments

You can also pass arguments by parameter name. These are called keyword arguments.

Example:

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

greet(name="Sam")

Output:

Hello Sam

This can be easier to read, especially when a function has several parameters.

def introduce(name, age):
    print(name, "is", age, "years old")

introduce(name="Maya", age=12)

Output:

Maya is 12 years old

Keyword arguments also help avoid mistakes with argument order:

introduce(age=12, name="Maya")

Output:

Maya is 12 years old

Even though the order in the call changed, Python still knows which value belongs to which parameter because the names were included.

To learn more, see default and keyword arguments explained.

Default parameter values

A parameter can have a default value.

That means the function can still run even if you do not pass an argument for that parameter.

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

greet()
greet("Maya")

Output:

Hello friend
Hello Maya

How this works:

  • If you call greet() with no argument, Python uses the default value "friend"
  • If you call greet("Maya"), Python uses "Maya" instead

Default values belong to the parameter, not the argument.

If you want a full beginner guide to this topic, read default and keyword arguments explained.

Common beginner mistakes

Here are some common problems beginners run into.

Calling a function with too few arguments

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

add(2)

This causes an error because the function expects two arguments, but only one was given.

You will usually get a TypeError. See how to fix missing required positional argument errors.

Calling a function with too many arguments

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

greet("Maya", "Sam")

This also causes a TypeError because the function only expects one argument.

Confusing parameter names with outside variable names

This works:

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

person = "Maya"
greet(person)

The parameter is name, but the outside variable is person.

They do not need to match.

Using the terms like they mean exactly the same thing

In everyday conversation, many people use these words loosely. But in Python learning, the distinction helps:

  • parameter = name in the function definition
  • argument = value in the function call

That small difference makes function code easier to read.

How to read function definitions and calls

When you see a function, use this simple process:

1. Look at the def line

The def line shows the parameters.

def area(width, height):
    return width * height

Parameters:

  • width
  • height

2. Look at the call line

The call line shows the arguments.

area(5, 3)

Arguments:

  • 5
  • 3

3. Count how many values the function expects

If the function has two required parameters, you usually need to pass two arguments.

4. Check whether the arguments are positional or keyword

Positional call:

area(5, 3)

Keyword call:

area(width=5, height=3)

Both can work, but they match values in different ways.

Common causes of confusion

Beginners often struggle with this topic for a few specific reasons:

  • Mixing up the function definition and the function call
  • Passing arguments in the wrong order
  • Forgetting a required argument
  • Assuming parameter names must match caller variable names
  • Confusing parameters and arguments with return values in Python functions

A return value is different. Parameters and arguments are about getting values into a function. A return value is about sending a value back out.

Simple debugging ideas

If a function call is not working, try these simple checks:

print(function_name)
help(function_name)
print(type(value))
print(a, b)

You can also try calling the function with simple literal values first.

For example, if this is not working:

greet(user_name)

try this first:

greet("Maya")

That helps you find out whether the problem is in the function itself or in the variable you passed.

FAQ

What is the difference between a parameter and an argument in Python?

A parameter is the name in the function definition. An argument is the value passed into the function when it is called.

Do the variable names outside the function need to match the parameter names?

No. Python matches positional arguments by order and keyword arguments by parameter name.

What happens if I do not pass enough arguments?

Python raises a TypeError because the function did not receive the required values.

When should I use keyword arguments?

Use them when they make the call easier to read or when you want to avoid mistakes with argument order.

Are default values the same as arguments?

No. A default value belongs to a parameter and is used only when no argument is passed for that parameter.

See also