Parameters and Arguments

Learn what parameters and arguments are and understand the difference between them.

We'll cover the following

There is always a little bit of confusion about parameters and arguments. Let me begin by saying that they are not the same. Parameters are the names of variables which define a function or a method. Arguments are values mapped to these parameters. In other words, arguments are passed or supplied through the function call and are stored in parameters so that it is accessible in the function body.

In the following example, num is the function parameter and the integer 3 is the argument passed to the function when it was called and is accessible inside the function body.

def double(num):
    return num*2


Mandatory and default parameters

In Python, by default, any parameter defined in a function is a mandatory parameter. If we miss them in function calls, we will run into errors. Python functions can also have optional parameters which are also called default parameters. Default parameters are parameters that do not necessarily have to be supplied during the function call. This works because, when we define optional parameters, we provide a default value to the parameter so that, when no value is supplied, the default value is used. The following implementation of functions in Python demonstrates how to define a mandatory and a default parameter.

Get hands-on with 1200+ tech skills courses.