C Language Functions | C++ Language Functions - A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.
As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions. These functions are called user-defined functions.
In Python a function is defined using the def keyword. For Example :
def functionname( parameters ):
Note : By default, parameters have a positional behavior and you need to inform them in the same order that they were defined.
To call a function, use the function name followed by parenthesis.
Information can be passed to functions as parameter. Parameters are specified after the function name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.
If we call the function without parameter, it uses the default value. The following example shows how to use a default parameter value :