--Originally published at Hackerman's house
A function is a structuring element that groups some lanes of code that can be utilized many times in the program. Is basically defining a formula to then just put the name of the formula, and the program will run it without the need of writing it again.
The syntax looks like this.
def name-of-the-function(Parameters):
Statements
The statements determine what your function will do.
To call a function you just need to put the name of a function previously defined.
name-of-the-function()
This is a really simple example about how to define a function and then call it two times. What this would do is run the same function two times. It is important to note that this function has no parameters.
And this is how the program works.
Besides this really simple program I created another that actually uses parameters.
This program executes a sum of the two parameters given.
And here it is how it works.
Thanks for reading me.