Parameter

A named variable in a function definition that receives an input value.

Parameters are the names listed in parentheses when you def a function. They act as placeholders: when the function is called, each parameter is filled with the matching argument. A parameter can have a default value, which makes it optional.

Example
def greet(name, greeting="Hello"):   # two parameters; greeting has a default
    return greeting + ", " + name

print(greet("Sam"))
print(greet("Sam", "Hi"))
Output
Hello, Sam
Hi, Sam

Where this shows up in real Python

Every function you write or call uses parameters — from a script’s settings to a web route’s inputs.

Commonly used Parameter tools

  • def f(a, b) — positional parameters
  • def f(a, b=10) — a default value makes it optional
  • def f(*args) — accept any number of positional values
  • def f(**kwargs) — accept any number of keyword values
  • def f(a: int) — type-hint a parameter

Official documentation: Python Glossary: parameter

Related lessons