Skip to main content

What are parameters?

Parameters let you pass data into functions. Instead of hardcoding values, you make functions flexible to work with different inputs.

Basic parameters

Add parameters inside the parentheses when defining a function:
The values you pass when calling a function are called “arguments”. The variables in the function definition are “parameters”. Many people use these terms interchangeably.

Multiple parameters

Functions can have multiple parameters:

Default values

Give parameters default values for optional arguments:
Put parameters with defaults at the end. Required parameters come first, optional ones last.

Keyword arguments

Call functions using parameter names for clarity:

Common mistakes

What’s next?

Functions become truly powerful when they can return values. Let’s learn how!

Return values

Get results from functions