Skip to content

parameter

In Python, a parameter is a variable that you use in a function or method definition to accept input values, known as arguments, when the function is called.

Parameters allow you to create flexible and reusable functions by letting you specify the input data that the function should work with. When you define a function, you can include parameters in the function’s signature. You can use these parameters as variables within the function body to perform computations.

There are different types of parameters in Python:

  • Positional-or-keyword parameters are the default kind and can receive arguments either by position or by name.
  • Positional-only parameters appear before / in the signature and can only be passed by position, not by name (Python 3.8+).
  • Keyword-only parameters appear after * in the signature and must be passed by name.
  • Parameters with default values have a default value that’s used if no argument is provided.
  • A variable number of parameters enables passing an arbitrary number of arguments to a function.

To see how Python matches each argument in a call to these parameter kinds, pick a call below and watch which parameter it binds to or which TypeError it raises:

Interactive diagram — enable JavaScript to view.

Parameters vs Arguments

When defining a function, you specify parameters in its signature. They act as placeholders for the arguments. When you call the function, you provide the arguments that correspond to these parameters.

Example

Here’s an example that demonstrates how to use parameters in a Python function:

Language: Python
def greet(name, greeting="Hello"):
    print(f"{greeting}, {name}!")

# Usage
greet("Alice")  # Output: Hello, Alice!
greet("Bob", "Hi")  # Output: Hi, Bob!

In this example, name is a regular positional-or-keyword parameter, while greeting is a parameter with a default value of "Hello". You can call the greet() function with just the name argument, or provide a custom value for greeting.

Using Python Optional Arguments When Defining Functions

Course

Defining Python Functions With Optional Arguments

In this video course, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create functions that accept any number of arguments using args and kwargs.

basics python

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Dec. 2, 2026 • Reviewed by Dan Bader