# Function parameters

The terms parameter and argument are often used synonymously. Parameters are variables that are declared in the function signature. Arguments are values that are used when the function is called. Parameters are declared in round brackets of the function signature. The parameters generally dictate how a function must be called.

In programming languages, a distinction is made between two main forms of parameter passing: call-by-value and call-by-reference. Python uses the mechanism of call-by-reference. The more accurate expression is actually call-by-object-reference. When calling a function, not pointers to variables but pointers to the underlying objects are passed.

How many parameters are passed to a method is up to the programmer and depends on the method definition. In Python, these parameters are called positional. The instances passed in the method call are assigned to the parameters according to their position in the parameter list.

In addition to the position-related parameters, there are also the keyword arguments. Keyword parameters are directly associated with the formal parameter name, and their order in the parameter list no longer matters.

It is also possible to mix position and keyword related parameters, but all keyword parameters must be at the end of the parameter list.

## Code Explanation

``````def max(a, b):
if a > b:
print(repr(a) + " > " + repr(b))
if a < b:
print(repr(a) + " < " + repr(b))

max(8, 6)
max(234.2, 253.1)
max(65, 65.3)``````
##### Output
``````8 > 6
234.2 < 253.1
65 < 65.3``````

## Another Example

### Code Explanation

``````def add(a = 10, b = 2):
return a + b

def sub(a = 10, b = 2):
return a - b

def mul(a = 10, b = 2):
return a * b

def div(a = 10, b = 2):
return a / b

# default function values
print(sub())
print(mul())
print(div())

# custom function values
print(sub(4, 3))
print(mul(4, 5))
print(div(36, 6))``````
##### Output
``````12
8
20
5.0
12
1
20
6.0``````

## Keyword arguments

``````def display(a, b, c, d):
print("a: " + str(a)
+ " b: " + str(b)
+ " c: " + str(c)
+ " d: " + str(d))

display(b=20, d=40, a=10, c=30)``````
##### Output
``a: 10 b: 20 c: 30 d: 40``